Posting characters like ® and ™ to a mySQL DB from PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tarenberg
Forum Newbie
Posts: 3
Joined: Mon Sep 11, 2006 10:57 am

Posting characters like ® and ™ to a mySQL DB from PHP

Post by tarenberg »

When I Post characters like ® and ™ to a SQL database from a PHP edit page ie:

Code: Select all

SQL string = INSERT INTO products (cat_id,product,pict,pict_path,description,notes,pl_no,web_no,settings,features,specs,pb,drawing,opt_acc,w_order,a_order,new) VALUES ("64","® ™ reg\'d","","","","","","","31","","","","","","","","")
The resulting entry ends up being " ® " and " ™ ", but when I take the SQL statement:

Code: Select all

INSERT INTO products (cat_id,product,pict,pict_path,description,notes,pl_no,web_no,settings,features,specs,pb,drawing,opt_acc,w_order,a_order,new) VALUES ("64","® ™ reg\'d","","","","","","","31","","","","","","","","")
and enter it into the database using phpMyAdmin the data is entered correctly, " ® ™ ".

Does anyone know how to eliminate this problem?

Thanks in advance
Tom
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

® = ® and ™ = ™

Use them instead! (In a HTML page they will apper like ® and ™.
tarenberg
Forum Newbie
Posts: 3
Joined: Mon Sep 11, 2006 10:57 am

Post by tarenberg »

I use the database for other things besides webpages. The same data is used for creating pricelists, excel spreadsheets and product bulletins. I'd rather not have to change the code in all those modules if I can resolve th problem at the editing level.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

You can use the ASCII numbers for these signs! (could be retrieved by chr()).
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Code: Select all

htmlspecialchars()
tarenberg
Forum Newbie
Posts: 3
Joined: Mon Sep 11, 2006 10:57 am

Post by tarenberg »

If I understand correctly htmlspecialchars() is for converting things like & to &. That's not what my problem is . I need to retain those special characters in the mySql database but for some reason they're being changed by PHP on the post statement. I'm already handeling their conversion to the web-centric values.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

You should ask your question in the MySQL help forum: http://forums.mysql.com/
You can also search in the sources listed on this page: http://www.mysql.com/support/community_support.html
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

tarenberg wrote:they're being changed by PHP on the post statement
I don't understand you. Can you explain further/give examples?
Post Reply