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);