Jump to content

Posting characters like ® and ™ to a mySQL DB from a PHP edit page gives bad res


tarenberg

Recommended Posts

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

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 " [b]®[/b] " and " [b]™[/b] ", but when I take the SQL statement:

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, " [b]® ™[/b] ".

Does anyone know how to eliminate this problem?

Thanks in advance
Tom
Try changing the datatype and collation of the table columns you expect to have these characters entered into. Honestly, I'm not an expert on datatypes so you may want to do a little research. I do know there are characters MySQL doesn't take. Take a look here:

http://www.xaprb.com/blog/2006/04/14/bad-character-data-in-mysql/

Also, while you don't need to specify every column in and UPDATE, you do in an INSERT, unless you have a default value assigned to that column.

Happy coding.

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.