Q695 Posted June 14, 2013 Share Posted June 14, 2013 How can I write the HTML, not have an sql escape error, and do the insert? <?php $img_src = ob_get_contents(); //25x25 html table of images being written by about 30 lines of PHP $sql_map_img="INSERT INTO map_image (`user`, `map_id`, `map_img`) VALUES ('$id', NULL, `$img_src`);"; //echo $sql_map_img; $result_creature = mysql_query($sql_map_img, $con) or die ("can not generate result " . mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted June 14, 2013 Share Posted June 14, 2013 put $img_src in single quotes, not backticks. (Backticks say "this is a column name") Quote Link to comment Share on other sites More sharing options...
Q695 Posted June 14, 2013 Author Share Posted June 14, 2013 can not generate result 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 '../images/clear.gif' alt='terain' height='20' width='20' /> Quote Link to comment Share on other sites More sharing options...
Barand Posted June 14, 2013 Share Posted June 14, 2013 I have just told you the solution Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted June 14, 2013 Solution Share Posted June 14, 2013 You need to escape $img_src as it contains quotes. mysql_real_escape_string Quote Link to comment Share on other sites More sharing options...
Q695 Posted June 15, 2013 Author Share Posted June 15, 2013 I feel silly, I shoud've thought that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.