Forum Moderators: coopster
here is the code for the city check
if(!(ereg("^([[:alpha:]]+([.¦-]?[[:space:]]?[[:alpha:]]+){2,})$", $_SESSION["city"])))
{
//do what I want here
}
the whole code is on one line and it works perfect but when I change the code to this...
if(!(ereg("^([[:alpha:]]+([\\'¦.¦-]?[[:space:]]?[[:alpha:]]+){2,})$", $_SESSION["city"])))
{
//whatever I want goes here
}
the code doesn't work and the output is displayed like this......
O\' Hare
i tried removing the slashes with the stripslashes to the output, but that just fixes the output but I still go in the if statement. I tried it with only one slash as well but same result. What am I doing wrong. why can't I escape ' should I use something else other than ereg or eregi. Thanks in advance for your help.
$_SESSION['city']variable is coming from <form> data. Are you familiar with PHP's magic quotes? The slash is probably already there from the submitted form data, meaning the city may already be quoted. The example on this page may help: get_magic_quotes_gpc [php.net]
If this is the case, why not stripslashes prior to edit-checks?