How do I add a new table to a database in MySQL with PHP code?
$con = mysql_connect (' localhost ', ' abc ', ' 123 ');
mysql_select_db (' SJK ');
$sql = "CREATE TABLE test (age int)");
mysql_query ($sql, $con);
Mysql_close ($con);
echo "table has been created.";
?>
Little brother experimented with the above code
The "table has been created" is already displayed in the browser.
But when you open SJK with phpMyAdmin,
But I didn't find the test table.
Excuse me, what is it?
How can you add a table to the database properly?
------Solution--------------------
Use database
------Solution--------------------
$sql = "CREATE TABLE test (age int)"; One more right parenthesis.
------Solution--------------------
$con = mysql_connect (' localhost ', ' abc ', ' 123 ');
mysql_select_db (' SJK ');
$sql = "CREATE TABLE test (age int)");----------? the wrong place.
mysql_query ($sql, $con);
Mysql_close ($con);
echo "table has been created.";