adamwhiles Posted June 28, 2006 Share Posted June 28, 2006 I am using the stripslashes function but it isn't working correctly here what I got:[code]$username = $_POST['username'];$Fname = $_POST['Fname'];$Lname = $_POST['Lname'];$email = $_POST['email'];$city = $_POST['city'];$state = $_POST['state'];$username2 = stripslashes($username);$Fname2 = stripslashes($Fname);$Lname2 = stripslashes($Lname);$email2 = stripslashes($email);$city2 = stripslashes($city);$state2 = stripslashes($state);[/code]Say $username = "f\s/d\f3/675"Now if i echo $username2 It will output f\s/d\f3/675 without stripping anythingAlso, how do I strip the forward slashes also? Quote Link to comment https://forums.phpfreaks.com/topic/13133-stripping-slashes-problem/ Share on other sites More sharing options...
wildteen88 Posted June 28, 2006 Share Posted June 28, 2006 stripslashes doesnt strip all slashes out of a string, it only strips slashes that is escaping certain characters:For example you had an apostrophe in your name, like so O'reily if you did this: O\'reily the backslash is escaping the apostrophe. Whn you use stripslashes on that name PHP will remove the slash, it'll also remove the slash if you had two backslashes. Such as \\ would be converted into \If you want to remove slashes completely use str_replace like so:[code]<?php$str = "This //string\\had slashes /\ in\\ it!";// Only strips out slashes that is escaping characters.echo stripslashes($str) . " - with stripslashes<br />\n\n";// use str_replace to remove \ and / characters from our string// NOTE: two \'s was used below to stop PHP from escaping the quote mark$str = str_replace(array("\\", "/"), '', $str);echo $str . '- with str_replace';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13133-stripping-slashes-problem/#findComment-50520 Share on other sites More sharing options...
adamwhiles Posted June 28, 2006 Author Share Posted June 28, 2006 Thanks, worked like a charm....I just didn't understand what stripslashes() done exactly I guess Quote Link to comment https://forums.phpfreaks.com/topic/13133-stripping-slashes-problem/#findComment-50558 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.