I am using this code to create a new table in a database I can connect to the database But i cannot create a new table or add data to an existing table I can select data from an existing table Is it something in my code? Thanks <?php $con = mysql_connect("mysql285.secureserver.net","database1","password"); if (!$con) { die('Could not connect: ' . mysql_error()); echo "could not connect"; } else { echo "connected"; } mysql_select_db("database1", $con); $sql = "CREATE TABLE Prods ( Product_ID bigint(100) NOT NULL AUTO_INCREMENT, Department varchar(20), Name varchar(50), Prod_code varchar(50), Description varchar (255), Picture varchar(50), Price decimal(8,2), Stock varchar(40), Prod_Type varchar(100))"; mysql_query($sql,$con); mysql_close($con); echo "<br />"; ?>
ok now i am getting this error any ideas?? "Incorrect table definition; There can only be one auto column and it must be defined as a key" thanks for all the help!
I agree with mad4 but I would like add another commend. For database handling, I would suggest using adodb rather than manually creating the wrapper from scratch. It may save you trouble.
even when i create a table in phpmyadmin i still cannot add data to it through php i am using godaddy to host the site and phpmyadmin is on godaddy i have created a database there but i can only read from the database i cannot insert or update data or create a new table
Copy and paste that error message into Google. You'll find lots of people who had this problem before. Works with every error message on earth. He has problems creating a database table and you come in here suggesting stuff like adodb and the likes? Dude, seriously, get real.
I saw his/her code and he/she is creating the wrappers around sql calls, so to save his/her life, i suggested using adodb. I know he/she had problems with db creation and that's why i said i agree with mad4 to use phpmyadmin... dude, seriously i m real