[RESOLVED] preg_replace question
I'm working on a user registration page for a personal project (a labor of love, heh) and am having a bit of an issue with preg_replace.
Basically, I have a Stored Procedure that will first check to see if a user has already registered. Primarily it checks first and last name; if the name doesn't yet exist in the database, then it checks email address; if there is not already a record in the database with that name OR email address, it inserts the data.
As far as the name check, I am sending the first and last name TWICE - first as the user entered it, then also I want to send the first and last name but replacing any spaces, apostrophes, or hyphens with the "%" wildcard (ie, if the user enters a first name of "La-Jenna", "La Jenna", or "La'Jenna", the search string will be "La%Jenna".)
But the preg_replace is not swapping out spaces, apostrophes, or hyphens. Here is my replace code:
If I enter "John-Paul" and echo $fNameCompare on submit, it shows as "John-Paul", not "John%Paul". What am I doing incorrectly?
$fNameCompare = preg_replace("/ '-/i","%",$_POST['firstName']);
$lNameCompare = preg_replace("/ '-/i","%",$_POST['lastName']);
I'm guessing what you actually want for your regexp is:
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks, NogDog.. I'll give that a shot next time I have my server up and running.
That was it! Thanks, NogDog!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)