PHP Build table is unsuccessful, but there is no error, solve the solution

Source: Internet
Author: User
PHP Build table unsuccessful, but also no error, solve
PHP Code
  
  

Page display: "No table", but after the execution of the table should be created, I will refresh the page or the "No table", please have a look at the king prawns to help you see God horse problem?

------Solution--------------------
Try:
PHP Code
        Connection Data $con =mysql_connect ("localhost", "root", "welcome123") or Die ("Unable to connect to database". Mysql_error ());        Determine if there is a My_project database $existDB =mysql_select_db ("My_project", $con);        echo "No My_project database";            if (! $existDB) {//create databases $CDATABSESQL = "CREATE Database My_project";            mysql_query ($CDATABSESQL, $con);  mysql_select_db ("My_project", $con);        Select Database} else {echo "has database";        }//Determine if there is a SendMail table $row =mysql_query ("Show Tables");        $database =array ();        $finddatabase = "SendMail";        while ($result =mysql_fetch_array ($row, Mysql_assoc)) {$database []= $result [' tables_in_test '];                } unset ($result, $row);                if (!in_array ($finddatabase, $database)) {echo "no table";               $CTABLESQL = "Create TABLE sendmail (ID INT auto_increment PRIMARY KEY, Tomail nvarchar (50), Subject nvarchar (a), message text) ";        mysql_query ($CTABLESQL, $con);            } else {echo "has a table"; } die ();
------Solution--------------------
Probably try this,

PHP Code
        if (! $existDB)        {            //create databases            $CDATABSESQL = "CREATE Database My_project";            mysql_query ($CDATABSESQL, $con);                    mysql_select_db ("My_project", $con);//Add a sentence, select the Library        } ...        Determine if there is a sendmail table        $row = Mysql_list_tables ("My_project");        $database =array ();        $finddatabase = "SendMail";        while ($result =mysql_fetch_array ($row))        {            $database []= $result [0];        }        Unset ($result, $row);
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.