Link to home
Start Free TrialLog in
Avatar of gingera
gingera

asked on

MYSQL PHP: How do we remove or escape ; (semi-colon) in data retrieved from a MySQL table field?

PHP MYSQL

Hello,

In a MySQL table field, I have ; (semi-colon) in it. When I retrieve the data in a PHP script, I get premature termination of the script because of the ; (semi-colon)


Example of table field:
"The quick brown fox jumps over the lazy dog; so does the elephant"
(semi-colon after dog)


Example of PHP script:

...
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
extract($row);
echo "$contents";
}


What do I do?
Avatar of afzz
afzz

why do you extract? it is unsafe

why dont you try this
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
//extract($row);
echo "$row->contents";
}
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gingera

ASKER

Hi Ray, sorry for the delay. I've just managed to test out the suggestions.

Your help is very much appreciated!
Avatar of gingera

ASKER

THANKS!!!