Jump to content

Words with apostrophe won't insert


TecTao

Recommended Posts

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,

 

Link to comment
https://forums.phpfreaks.com/topic/156049-words-with-apostrophe-wont-insert/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.