Problem with pound (£) in MySQL AR insert statements - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem with pound (£) in MySQL AR insert statements (/showthread.php?tid=7507) Pages:
1
2
|
Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]Unknown[/eluser] Using the following line of code, when $strFile includes the British pound symbol (£), I receive the error listed below. Has anyone else experienced this issue? Code: Code: $this->db->insert('names', array('Name' => $strFile)); Result: Code: ERROR - 2008-04-09 01:01:34 --> Query error: Incorrect string value: ‘\xA3.java’ for column ‘Name’ at row 1 Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]Tom Glover[/eluser] As far as I know MySQL is not a fan of the £ sign so if you need to store it in there it will need to be in it's html code form, and not the symbol. Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]Unknown[/eluser] Well, I manually executed Quote:INSERT INTO table SET field='blahblah£.java' and it worked. Apparently it doesn't like the way CodeIgniter is escaping it with the \xA3. Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]Tom Glover[/eluser] OK try using the html version of the £ with the CI method and see if that works. Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]_asdf[/eluser] [quote author="WackyWebs.net" date="1208016706"]OK try using the html version of the £ with the CI method and see if that works.[/quote] that's not a solution, its a hack. And its based on the presumption that the intended output is an HTML (or SGML) renderer. (fwiw, I'll try and replicate the issue at hand later to confirm its a CI escape/convert bug) Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]xwero[/eluser] try Code: $this->db->set('Name',$strFile,false); Problem with pound (£) in MySQL AR insert statements - El Forum - 04-12-2008 [eluser]Derek Jones[/eluser] What is your database character set and collation, and what version of MySQL? I don't have any problems inserting £. Problem with pound (£) in MySQL AR insert statements - El Forum - 04-13-2008 [eluser]_asdf[/eluser] Alrighty, I've tested against a default Codeigniter 1.6.1 (stable) install, replacing the welcome controller and connecting to a database with the table format: Code: DROP TABLE IF EXISTS `test`; While the DB structure there specifies latin1 general, I've also tested it as utf8 general. Welcome controller method: Code: function index() In both instances, GBP symbol was inserted correctly. In both latin1 and utf-8. with the file saved as both ANSI and utf8 (although the profiler returns the GBP as a questionmark, typical of encoding problems, the data is inserted correctly) So we need more details: Database collation, the database.php specified collation. The data you're inserting, and any validation/filtering its going through. Is XSS clean enabled? etc. XML output of the table: Code: <char_test> Problem with pound (£) in MySQL AR insert statements - El Forum - 01-12-2009 [eluser]Max_Power[/eluser] OK, I am having a similar problem in CI 1.7, too. It doesn't seem to be just putting the the GBP in the database that's an issue: Code: CREATE TABLE IF NOT EXISTS `options` ( In codeigniter: Code: $data = array( This puts in a '?' instead of a '£', even though the last_query() function displays the pound symbol correctly. When the '£' symbol is retrieved, the active record set causes problems as it turns the '£' into '£'. Very strange. mySQL version: 5.0.51a-3ubuntu5.4 Problem with pound (£) in MySQL AR insert statements - El Forum - 01-12-2009 [eluser]Max_Power[/eluser] Even stranger - if I submit the value as £, then it is stored in mySQL as £... |