mysql data entry

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
User avatar
Gavski
Forum Newbie
Posts: 19
Joined: Thu May 16, 2002 2:30 pm
Location: UK

mysql data entry

Post by Gavski »

I am trying to input <TEXT AREA>data into a mysql database field using PHP. Any text that appears after a colon ' does not get entered into the field. IE,
Hello it's a nice day
appears as Hello it
the rest of the data is lost.
I've tried using tried using addslashes()/stripslashes()
stripslashes() removes \ from the text but still looses the string.
addslashes() stores Hello it\\\\ the rest disapears.

This is basic, surely???
anyone help??
Thanks.
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

hmmm.... i seem to remember

Post by cwcollins »

i seem to remember running into this problem with a student of mine, and while we never figured out what was causing it, the solution was to do a stripslashes() and follow that with an addslashes() on the resulting string. i could be mistaken, but it doesn't hurt to try.

-c.w.collins
User avatar
ILoveJackDaniels
Forum Commoner
Posts: 43
Joined: Mon May 20, 2002 8:18 am
Location: Brighton, UK

Post by ILoveJackDaniels »

Another quick fix for this is to use the following code on the data entered into the field before ANYTHING else:

Code: Select all

eregi_replace("'","&apos;",$textarea_data);
User avatar
Gavski
Forum Newbie
Posts: 19
Joined: Thu May 16, 2002 2:30 pm
Location: UK

Thanks

Post by Gavski »

Thanks for your replys, I've cracked it now,

$message=urlencode($message); allows all data to be passed, then
urldecode(); returns it to original format.

The ereg_replace() sound interesting, I will have alook at that,

Thanks again all.
Post Reply