ejwf wrote:thanks for this, but doesn't this change the character into something else?
In the manual it says when using htmlentities($str);
a single quote ' is replaced with ' which isn't exactly what I want......
I want to remove the single quote or replace it with a space......
thanks
I would go with [MAN]str_replace[/MAN]. The above example of using ereg_replace would work, but for a simple task like this str_replace will work fine. If you want a number of characters to be replaced by either a blank space or even to strip them and not replace with anything, you can either replace one item or replace an array.
You could change:
$ClientId = addslashes($data[0]);
$ClientName = addslashes($data[1]);
$Address1 = addslashes($data[2]);
To:
$array_of_invalid_characeters=array("\'","\"");
$ClientId = str_replace($array_of_invalid_characters,"",$data[0]);
$ClientName = str_replace($array_of_invalid_characters,"",$data[1]);
$Address1 = str_replace($array_of_invalid_characters,"",$data[2]);
If you're doing a lot of stuff like this on a regular basis, you might want to consider creating a string replacement class and just have functions that do this kind of work for you. It would make things look a little cleaner if this sort of thing occurs frequently in your code.