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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.