Michan Posted November 13, 2007 Share Posted November 13, 2007 Hi, I'm having problems sending a serialized chunk of text to the database, and I believe it's due to the semicolon. $general = serialize($_POST['general']); mysql_query('UPDATE users SET general = "'.$general.'" WHERE userid ='.$_POST['userid']) or die(mysql_error()); The error I'm delivered with is: "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 'name";s:0:"";s:9:"residence";s:0:"";s:11:"nationality";s:0:"";s:5:"likes";s:0:""' at line 1" Could somebody please help me here? Many thanks in advance. - Mi Link to comment https://forums.phpfreaks.com/topic/77121-solved-problems-with-serializing-and-semicolon/ Share on other sites More sharing options...
Orio Posted November 13, 2007 Share Posted November 13, 2007 Try it this way: <?php $general = serialize($_POST['general']); mysql_query("UPDATE users SET general = '".$general."' WHERE userid ='".$_POST['userid']."'") or die(mysql_error()); ?> If that still produces the error, run this and post here the output you got (the error). <?php $general = serialize($_POST['general']); $query = "UPDATE users SET general = '".$general."' WHERE userid ='".$_POST['userid']."'"; mysql_query($query) or die($query."<br />".mysql_error()); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/77121-solved-problems-with-serializing-and-semicolon/#findComment-390561 Share on other sites More sharing options...
Daukan Posted November 13, 2007 Share Posted November 13, 2007 You have to run mysql_real_escape_string() after you serialize. Link to comment https://forums.phpfreaks.com/topic/77121-solved-problems-with-serializing-and-semicolon/#findComment-390562 Share on other sites More sharing options...
Michan Posted November 13, 2007 Author Share Posted November 13, 2007 Try it this way. Orio. Thanks Orio, it works perfectly! I can't believe I didn't think of that. Solved! Link to comment https://forums.phpfreaks.com/topic/77121-solved-problems-with-serializing-and-semicolon/#findComment-390564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.