Jump to content

how to correctly insert a £ into mysql table so it shows as a £ and not A£


jasonc

Recommended Posts

this is an extract of my mysql table...

CREATE TABLE IF NOT EXISTS `table` (
  `id` int(25) NOT NULL auto_increment,
  `additionalInfo` text NOT NULL,
  `cost` varchar(100) NOT NULL,
  `admin_reply` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

the fields that are not showing the £ sign are 'cost' and 'admin_reply'

ok i now got it to store in the mysql as a £ not the A£ using the following method..

 

placing

mysql_query("SET NAMES 'utf8'");

just below the call to mysql_select_db();

 

but still in the email text it shows as A£

 

the data is grabbed from mysql and placed in a string as is, then placed in a $_SESSION and then once the form is sumitted the new page formats the email text using strings and this is added to the email html, again none of these strings that have the £ are altered in anyway.

Same thing:

mysql_set_charset('utf-8') == mysql_query("SET NAMES 'utf8'")

 

php recommends mysql_set_charset over mysql_query("SET NAMES 'utf8'")

 

when you pull the data out of the database, I don't think you want to use mysql_set_charset over mysql_query("SET NAMES 'utf8'"). I believe I had that problem once, by removing that, it came out normal (it may have been vise versa but I don't think so).

so when i insert i use

mysql_set_charset('utf-8');

 

and when i grab i do not use the above ?

 

that is going to be really hard to do as the connection.inc file is in every file that uses a database connection !

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.