Page 1 of 1

mysql data entry

Posted: Thu May 16, 2002 2:30 pm
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.

hmmm.... i seem to remember

Posted: Mon May 20, 2002 9:57 am
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

Posted: Mon May 20, 2002 10:22 am
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);

Thanks

Posted: Mon May 20, 2002 12:17 pm
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.