TecTao Posted April 29, 2009 Share Posted April 29, 2009 I've run into a situation now, didn't seem to have it before I switched hosting companies, but words with apostrophes won't insert from text boxes or fields into tables that are text, medium text, longtext and varchar. Non apostrophe words still do. I've been using the following and still won't insert. <?php $n_desc=addslashes(htmlspecialchars($_POST['n_desc'])); //or $n_desc=addslashes($_POST['n_desc']); //or $n_date = mysql_real_escape_string ($_POST['n_date']); ?> Nothing works, Anyone run into this or have any solutions. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/ Share on other sites More sharing options...
Helmet Posted April 29, 2009 Share Posted April 29, 2009 Maybe try converting to different character sets? Shot in the dark. Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/#findComment-821510 Share on other sites More sharing options...
chmpdog Posted April 29, 2009 Share Posted April 29, 2009 whats the code for the insert? Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/#findComment-821512 Share on other sites More sharing options...
neogemima Posted April 29, 2009 Share Posted April 29, 2009 This looks like a textbook case of addslashes not working. Whats your code for the entry look like in your form? Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/#findComment-821524 Share on other sites More sharing options...
premiso Posted April 29, 2009 Share Posted April 29, 2009 Avoid using addslashes for database entries. There is a reason mysql_real_escape_string was created. <?php $n_desc=mysql_real_escape_string(htmlspecialchars($_POST['n_desc'])); Should be all you have to do. Adding slashes should not be used as this there is a function designed for this specific event. Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/#findComment-821526 Share on other sites More sharing options...
Helmet Posted April 29, 2009 Share Posted April 29, 2009 If your new host uses a different default character set for for their MySQL and your input apostrophes are curly or something crazy like that (I'm not an expert on character encoding, but I have encountered a similar issue) then this could be causing an error. Quote Link to comment https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/#findComment-821530 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.