SQL insert statement not working
Posted: Mon Nov 09, 2009 8:25 pm
I have no idea why this insert statement is not working. I even tried using the statement directly from phpmyadmin and its still not working. I'm thinking its something terribly stupid. variables are cleared using addslashes(); and mysql_escape_string(); for the content variable Thanks in advance.
Sql Insert String:
$sql="INSERT INTO users(id,email,from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'$email','$from','$content','$subject','$cat1','$cat2','$cat3',$active,'$username','$password')";
Below is the $sql echo'ed out into the browser:
INSERT INTO users(id,email,from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'its@nicknguyen.com','Nicholas N','Hi Thank You in Advance for your time.\r\nNick N\r\nIts@NickNguyen.com\r\n\r\nhttp://www.NickNguyen.com','Subject of email','cpg','crg','cps',0,'its.nicknguyen@mail.com','password')
Error Message from mysql_error():
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'its@ni' at line 1
Sql Insert String:
$sql="INSERT INTO users(id,email,from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'$email','$from','$content','$subject','$cat1','$cat2','$cat3',$active,'$username','$password')";
Below is the $sql echo'ed out into the browser:
INSERT INTO users(id,email,from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'its@nicknguyen.com','Nicholas N','Hi Thank You in Advance for your time.\r\nNick N\r\nIts@NickNguyen.com\r\n\r\nhttp://www.NickNguyen.com','Subject of email','cpg','crg','cps',0,'its.nicknguyen@mail.com','password')
Error Message from mysql_error():
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from,subject,content,cat1,cat2,cat3,active,username,password)VALUES(NULL,'its@ni' at line 1