Page 1 of 1

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

Posted: Mon Sep 11, 2006 11:02 am
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

Posted: Mon Sep 11, 2006 11:26 am
by ok
® = ® and ™ = ™

Use them instead! (In a HTML page they will apper like ® and ™.

Posted: Mon Sep 11, 2006 12:04 pm
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.

Posted: Mon Sep 11, 2006 12:11 pm
by ok
You can use the ASCII numbers for these signs! (could be retrieved by chr()).

Posted: Mon Sep 11, 2006 12:14 pm
by jayshields

Code: Select all

htmlspecialchars()

Posted: Mon Sep 11, 2006 12:31 pm
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.

Posted: Mon Sep 11, 2006 1:04 pm
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

Posted: Mon Sep 11, 2006 1:09 pm
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?