Page 1 of 1

Submitting greater or less than

Posted: Thu Oct 16, 2008 12:31 pm
by icesolid
I am having a problem when submitting values to the database from a form on the web.

If any of the form values have a greater or less than sign in them it drops off the sign and anything after it when it submits to the database.

Should I be using some other type of encoding for the field?

Does latin1 or utf-8 for the collation type have anything to do with this problem?

Re: Submitting greater or less than

Posted: Thu Oct 16, 2008 1:27 pm
by onion2k
It should be fine submitting those to a database so long as you're enclosing the string in quotes (and escaping the data). What's more likely to be happening is that when you output the data again in an HTML page the browser thinks you're opening a tag because you haven't converted the < and > into < and > using htmlentities() or htmlspecialchars().

Re: Submitting greater or less than

Posted: Thu Oct 16, 2008 1:41 pm
by icesolid
When the this value Light (<10k) is submitted to the databse. I then go to phpMyAdmin to look at that field and all that shows up in there is Light (

Re: Submitting greater or less than

Posted: Thu Oct 16, 2008 1:42 pm
by onion2k
Post the SQL you're using to insert it.

Re: Submitting greater or less than

Posted: Thu Oct 16, 2008 1:54 pm
by icesolid

Code: Select all

mysql_query("UPDATE `table` SET `field`='" . $_POST["field"] . "' WHERE `id`='" . $_POST["id"] . "'");

Re: Submitting greater or less than

Posted: Fri Oct 17, 2008 9:45 am
by icesolid
Any ideas?