Solarpitch Posted November 26, 2008 Share Posted November 26, 2008 Hey, I'm trying to submit a form to my database but it's telling me.. 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 'Sullivan John Mr','','','test 3')' at line 3 The reason being that the name is O'Sullivan John but I think the apostrophe is causing the issue. I tried the following code to rplace the ' with a blank space but it just make the whole name blank. Is there anyway I can still use the apostrophe in the name without having to replace it for the DB? <?php $member= $_SESSION['member']; $strip = array("'"); $member = str_replace($strip, "", " "); /> Link to comment https://forums.phpfreaks.com/topic/134358-solved-slight-issue-with-str_replace-with-apostrophe/ Share on other sites More sharing options...
Adam Posted November 26, 2008 Share Posted November 26, 2008 you can use mysql_real_escape_string() to avoid problems like this.. http://uk.php.net/mysql_real_escape_string Adam Link to comment https://forums.phpfreaks.com/topic/134358-solved-slight-issue-with-str_replace-with-apostrophe/#findComment-699501 Share on other sites More sharing options...
Solarpitch Posted November 26, 2008 Author Share Posted November 26, 2008 Oh yeah.. forgot about that.. thanks Link to comment https://forums.phpfreaks.com/topic/134358-solved-slight-issue-with-str_replace-with-apostrophe/#findComment-699525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.