![]() |
escape_str Anomaly? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: escape_str Anomaly? (/showthread.php?tid=31273) |
escape_str Anomaly? - El Forum - 06-12-2010 [eluser]Vik[/eluser] In my database config file, I have: Code: $db['default']['char_set'] = "utf8"; ...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 '; ...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. escape_str Anomaly? - El Forum - 06-18-2010 [eluser]Ener1[/eluser] Hey, did you tryed to use htmlentities ? escape_str Anomaly? - El Forum - 06-18-2010 [eluser]Vik[/eluser] Thanks for the suggestion, Ener1. I fixed this. It had nothing to do with escape_str per se. I still don't know exactly why it happened. It was some idiosyncrasy in my code. Something to do with how the $_RESULT array was being handled and how I was using it. ![]() escape_str Anomaly? - El Forum - 06-18-2010 [eluser]Ener1[/eluser] Could be great to know, just in case it happeds to anyone else ![]() |