Welcome Guest, Not a member yet? Register   Sign In
escape_str Anomaly?
#1

[eluser]Vik[/eluser]
In my database config file, I have:

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

...and in config.php I have:

Code:
$config['charset'] = "UTF-8";

I am trying to store the following string to a mySQL table, using an Ajax call:

Quote:Academia-Gate — the Nanny State & The Professors: My Brief Email Exchange With The Co-Chair of the “Cry Wolf” Project

The string arrives at my php Ajax handler function looking like this:

Quote:Academia-Gate — the Nanny State & The Professors: My Brief Email Exchange With The Co-Chair of the “Cry Wolf” Project

When I try to store it to my mySQL table, the string is stored like this:

Quote:Academia-Gate ??" the Nanny State & The Professors: My Brief Email Exchange With The Co-Chair of the “Cry Wolf” Project

I.e. with ??" in place of the long dash near the beginning.

I have tracked this down to something that happens during the function escape_str, in DB_driver.php. The escape_str function utilizes a call to mysql_real_escape_string.

The following code:

Code:
$str = 'Academia-Gate — the Nanny State & The Professors: My Brief Email Exchange With The Co-Chair of the “Cry Wolf” Project ';
$str = mysql_real_escape_string($str, $this->conn_id);

...changes the contents of $str to:

Code:
Academia-Gate ‚Ä\" the Nanny State & The Professors: My Brief Email Exchange With The Co-Chair of the ‚ÄúCry Wolf‚Äù Project

I.e. it replaces >>>‚Äî<<< with >>>‚Ä\"<<<, so that it is then stored incorrectly in the mySQL table.

How can I correct this?

Thanks very much in advance to all for any info.


Messages In This Thread
escape_str Anomaly? - by El Forum - 06-12-2010, 01:00 PM
escape_str Anomaly? - by El Forum - 06-18-2010, 04:32 PM
escape_str Anomaly? - by El Forum - 06-18-2010, 04:47 PM
escape_str Anomaly? - by El Forum - 06-18-2010, 04:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB