Posted by:
wilfred_phang
(---.60.in-addr.arpa.tm.net.my)
Hi, i would like to ask why the database is not successfully created when i'm using AUTO_INCREMENT in for the primary key? Below is my code:
<?php
$con = mysql_connect("localhost","root",""
;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
/*
// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
*/
// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE People
(
P_ID varchar(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(P_ID),
P_Name varchar(20),
P_Pswd varchar(20),
)";
// Execute query
mysql_query($sql,$con);
mysql_close($connect);
?>
Please help me to solve this problem. Thanks!