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. Quote Link to comment Share on other sites More sharing options...
Broniukas Posted June 19, 2007 Share Posted June 19, 2007 " O\'Brian " Quote Link to comment Share on other sites More sharing options...
Gnub Posted June 19, 2007 Author Share Posted June 19, 2007 cheers Quote Link to comment 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); ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. 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.