Jump to content

syntax error


182x

Recommended Posts

Hey guys,

 

Just wondering what is wrong with the following syntax, I was also wondering id there a way to split the insert statement so it can appear over multiple lines?

 

Thanks

 

 

$st=mysql_fetch_array($query2)
$sto="INSERT INTO em VALUES ('','$st['1]','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']')";

 

error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\a\t\te.php on line 55

Link to comment
https://forums.phpfreaks.com/topic/60593-syntax-error/
Share on other sites

when incorporating array items into a string to be interpolated, you should generally put curly braces around the array item:

 

$sto="INSERT INTO em VALUES ('','{$st['1']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}')";

 

you also forgot a closing single quote on $st['1'].

Link to comment
https://forums.phpfreaks.com/topic/60593-syntax-error/#findComment-301428
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.