Submitting greater or less than

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
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Submitting greater or less than

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Submitting greater or less than

Post 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().
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: Submitting greater or less than

Post 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 (
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Submitting greater or less than

Post by onion2k »

Post the SQL you're using to insert it.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: Submitting greater or less than

Post by icesolid »

Code: Select all

mysql_query("UPDATE `table` SET `field`='" . $_POST["field"] . "' WHERE `id`='" . $_POST["id"] . "'");
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: Submitting greater or less than

Post by icesolid »

Any ideas?
Post Reply