zeem Posted April 26, 2007 Share Posted April 26, 2007 here is my error 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 'order (name,cid,color,size) VALUES ('767','1','blue', '11')' at line 1 so i asume that its a syntax errory here is the code in question $size=$_POST['size']; $color=$_POST['color']; $name=$_POST['order']; $cid = "1"; $connection = mysql_connect('localhost','localhost','') or die ('Connection issue'); mysql_select_db('archive') or die('database issue'); $query = "INSERT INTO order (name,cid,color,size) VALUES ('$name','$cid','$color', '$size')"; $result= mysql_query($query) or die("fuck : $query" . mysql_error()) ; see anythying wrong? i dont Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/ Share on other sites More sharing options...
AndyB Posted April 26, 2007 Share Posted April 26, 2007 ORDER is a reserved MYSQL word. You can't use order as a table name (or field name). Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238696 Share on other sites More sharing options...
zeem Posted April 26, 2007 Author Share Posted April 26, 2007 oh snap! thankx Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238698 Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 Yeah these can be difficult sometimes, most of the time I manually insert one into the SQL and use the code they give me that i executed and replace the inputs with my variables. Uhm, the next best thing to try would be: $size=$_POST['size']; $color=$_POST['color']; $name=$_POST['order']; $cid = 1; $connection = mysql_connect('localhost','localhost','') or die ('Connection issue'); mysql_select_db('archive') or die('database issue'); $query = "INSERT INTO order (name,cid,color,size) VALUES (\"".$name."\",\"".$cid."\",\"".$color."\",\"".$size."\");"; $result= mysql_query($query) or die("fuck : $query" . mysql_error()) ; edit: Well that's how I'd go about it when this is a legitamate problem :-D Well there you go:) Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238699 Share on other sites More sharing options...
zeem Posted April 26, 2007 Author Share Posted April 26, 2007 a legitamit problem? wat makes htis less lagit than anyothe problem????????? HMMMMM?? just kididng, i did use ur method, of cut an pasteing out of a query thats y i was having such a hard time understanding my the error? Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238724 Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 Well, I didn't know order was a reserved name, so therefore i referred problems where it isnt about reserved names as legit Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238727 Share on other sites More sharing options...
AndyB Posted April 26, 2007 Share Posted April 26, 2007 For future reference: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/48714-error-in-mysql-php/#findComment-238942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.