Page 1 of 1
[Solved] Stripslashes
Posted: Thu Feb 09, 2006 9:37 am
by Moocat
Stripslashes isn't working for me for some reason, could it be a wrong setting? (magic quotes are on)
Code: Select all
Tag strip
<br><br>
<?php
if(isset($_POST['test'])) {
$text = $_POST['test'];
//$text = strip_tags($text);
echo stripslashes($text);
}
?>
<form action="new3.php" method="post">
<input type="text" name="test">
<input type="submit">
</form>
Posted: Thu Feb 09, 2006 9:52 am
by Jenk
What do you mean by isn't working? There is nothing in your post/example that indicates it isn't working.
What is the user input? What is the output both with and without stripslashes?
Posted: Thu Feb 09, 2006 9:52 am
by pickle
Echo $text before calling stripslashes and see what you get.
Posted: Thu Feb 09, 2006 11:37 am
by Moocat
It isn't working as in:
enterted input: test / test
ouput: test / test
EDIT: I found out that it only strips \ slashes not / slashes. And even then it doesn't seem to be working right.
entered input: test \ test
output (before strip): test \\ test
output (after strip): test \ test
Weird, any reason why this happens? By the way, I placed this in secruity because I'm looking for an all around good input text parser. Figured it's more specifically related to security although I understand I did not initially state so.
Posted: Thu Feb 09, 2006 11:46 am
by Jenk
/ is not an escape character, \ is and escaping character, used both by PHP and MySQL (amongst others).
Posted: Thu Feb 09, 2006 12:04 pm
by Moocat
Jenk wrote:/ is not an escape character, \ is and escaping character, used both by PHP and MySQL (amongst others).
Thanks, problem solved

I guess I should've explained my reasons for asking more thoroughly in the first place.