wilfred_phang Posted February 10, 2009 Share Posted February 10, 2009 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 databaseif (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; }*/// Create tablemysql_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 querymysql_query($sql,$con);mysql_close($connect);?>Please help me to solve this problem. Thanks! Link to comment Share on other sites More sharing options...
Lulzim Posted February 10, 2009 Share Posted February 10, 2009 it is because the column type is varchar. it should be numeric (int, mediumint...) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.