Welcome Guest, Not a member yet? Register   Sign In
Problem with pound (£) in MySQL AR insert statements

[eluser]Derek Jones[/eluser]
What's the character set being delivered by the server and web page? Your database table is latin1, an odd choice, IMO, but I suspect you're just criss-crossing character sets. If you have a link to the page with the output, that would be helpful to someone wanting to assist you in confirming or ruling that out.


I've set up a test page at http://maxpower.plus.com.

The output is currently two data columns - opt and value, which are displayed in a for-each loop.


Just adding an input field...

[eluser]Derek Jones[/eluser]
Your server appears to be forcing utf-8 headers - if I set my browser to view that page as utf-8, it displays properly. You could have that disabled, but you'd be better off to convert your database to utf-8 and use utf-8 exclusively throughout your application and site.

Thanks for that. I set up this test with UTF-8:

  `opt` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL,
  PRIMARY KEY  (`opt`)

Still doesn't return the GBP symbol correctly...

[eluser]Derek Jones[/eluser]
Yes, but what are your charset and collation settings in your CI db driver?


They are in UTF-8 as well:

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

[eluser]Derek Jones[/eluser]
I would see if it makes a difference if you enter the data via a utf-8 encoded web page from a form. Say, from phpMyAdmin with utf-8 selected, or CI's deprecated-but-still-exists scaffolding. And for certain, I'd ask the server admin to disable the feature of forcing a character set, and construct proper HTML output including a meta tag defining the correct character set. At it's base, what you have is a simple problem of multiple points not communicating to each other in the same character set, but if your configuration is set properly, CI really isn't involved there.

Bang on!

Thanks for your help. In my main app I set the character set to iso-8859-1 probably from copying and pasting some old code.

I was using phpMyAdmin (which was fine) and I double-checked the scaffolding which was also having no problems.

Using utf-8 in my header now and all is well.

Thanks again - you're a star!

[eluser]Derek Jones[/eluser]
Glad we could help, Max_Power, and welcome to the community!

Theme © iAndrew 2016 - Forum software by © MyBB