Parsing ' 's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Parsing ' 's

Post by Straterra »

I have a datebase, but when I try to enter things into it with ' 's in it, it returns a '' instead of '. I wrote this simple function to try to fix it, but it doesn't seem to work!

Code: Select all

function fromsafe($var1) {
$var2 = "''";
$var3 = "'";
return(ereg_replace($var2, $var3, $var1));
}

The ' 's still have a \ infront of them. Help!
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

$var1 = stripslashes($var1);

Check out [php_man]stripslashes[/php_man] for more info.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Post Reply