Hey all, Im getting an internal server error with the following basic script, the page has permissions of 777 <?php //// database login info taken out mysql_connect($db_host, $db_username, $db_password) or die("Connection Failed"); mysql_select_db($db_name)or die("Connection Failed"); $user = 'Paul'; $tittle = 'testspaw'; $subtittle ='testspaw'; $qis = 'testspaw'; $condition = 'testc'; $pound = 'testspaw'; $spaw = 'testspaw'; $query = "INSERT INTO products(user,tittle,subtittle,quantity,condition,priceq,descripton)VALUES('$user','$tittle','$subtittle','$qis','$condition','$pound','$spaw')"; if(mysql_query($query)){ echo "inserted";} else{ echo "fail";} ?> PHP: Any help is much appreciated Thanks Paul
mysql_select_db($db_name)or die("Connection Failed"); must be mysql_select_db($db_name) or die("Connection Failed"); and please rewrite this if(mysql_query($query)){ echo "inserted";} else{ echo "fail";} to something like this if ($statement) { // do this } else { // do this }
Ive updated a line of text to mysql_query("INSERT INTO products (user,tittle,subtittle,quantity,condition,priceq,descripton) VALUES('$user','$tittle','$subtittle','$qis','$condition','$pound','$spaw')") or die(mysql_error()); PHP: And i am getting the error, Can anyone spot the problem? Thanks for your help guys
Delimit field names with `user`,`title` ... Also use phpmyadmin to try your queries. Have your script echo that sql string and run that in phpmyadmin. mysql_query($sql="INSERT ... echo $sql;