Jump to content

White space on the middle


erok

Recommended Posts

Hi everyone, I have this statement , $phone = ($_POST['phone']);$phone = trim($phone, "\" \""); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone); when user enter phone number into phone field such as;954 333 or 954333I want database register phone number to tablelike 954333 without white space, even if the user type in 954 333.I tried trim or regexp. They did not work out.What function i should use to strip off automatically any white space in the middle.Any help appreciatedErok

Link to comment
Share on other sites

Hi justsomeguy,I tried these codes below they did not make difference.They did not strip off white space$phone = ($_POST['phone']);$phone = str_replace("\" \"", "\"empty()\"", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);and$phone = ($_POST['phone']);$phone = str_replace("\" \"", "\"\"", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);

Link to comment
Share on other sites

Sorry I tried this one also.It did not work.$phone = ($_POST['phone']);$phone = str_replace("\" \"", "empty()", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);with these codes program running fine.Just not stripping off white space.

Link to comment
Share on other sites

Thanks for help.This code running properly. It strips off white space. $phone = ($_POST['phone']);$phone = str_replace(" ", "", $phone); // Strip off white spaces $phone = mysql_real_escape_string($phone);$phone = addslashes($phone);Erok

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...