Jump to content

error in Mysql PHP


zeem

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.