Gnub Posted June 19, 2007 Share Posted June 19, 2007 When ever i try to insert a record, and one of the fields contains a apostrophe, ( ' ), it throws an error at me. So for example, if i try to insert a name called " O'Brian " , it wont accept it. Is there anything i can do, either on PHP or on the MySQL database to solve this small issue? changing of character sets? or something? Thanks in advance. Gnub. Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/ Share on other sites More sharing options...
Broniukas Posted June 19, 2007 Share Posted June 19, 2007 " O\'Brian " Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277514 Share on other sites More sharing options...
Gnub Posted June 19, 2007 Author Share Posted June 19, 2007 cheers Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277515 Share on other sites More sharing options...
Dragen Posted June 19, 2007 Share Posted June 19, 2007 what error do you get? you could try using addslashes. <?php $variable = "O'brien"; $variable = addslashes($variable); ?> Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277516 Share on other sites More sharing options...
Gnub Posted June 19, 2007 Author Share Posted June 19, 2007 basically, what i've done is used a str_replace, to add the slashes. I could use the add slash, see which one im happy using. Error was basically, you have an error in your sql query, no specific info, but i discovered it was with the apos. Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277520 Share on other sites More sharing options...
Dragen Posted June 19, 2007 Share Posted June 19, 2007 addslashes would be better the str_replace as that's what's it's for Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277527 Share on other sites More sharing options...
Gnub Posted June 19, 2007 Author Share Posted June 19, 2007 yeah, just found out the long way. Thanks. Link to comment https://forums.phpfreaks.com/topic/56184-solved-apostrophe-problems/#findComment-277538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.