Welcome to WebmasterWorld Guest from 54.145.95.149

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Problem removing slashes with stripslashes

php stripslashes function not working

     
5:04 pm on Oct 23, 2007 (gmt 0)

New User

10+ Year Member

joined:May 15, 2003
posts:28
votes: 0


Hello,

I have a problem with removing slashes which are added to my text in my php pages.

I have tried to add the stripslashes () function to every possible variable but nothing seems to remove the slashes. VAR5 is the text that is added to my pages. Can someone tell me what I'm doing wrong? Here is the code:

$var1 = strtolower($rslt1[$j][title]);
$var2 = ucfirst($var1);
$var3 = str_replace(" ","_",$var1);
$var4 = strtoupper($var3);

$var5 = stripslashes(str_replace("_"," ",$var4));

for ($l=0 ; $l<strlen($var5); $l++)
{
$le = $var5[$l];

if (@in_array($le, $special_char1))
{

foreach($upper_char as $key => $value)
{
if ($var5[$l]==$key)
$var5 = str_replace($key, $value, $var5);
}
}

}

$var5 = strtoupper($var5);

Thanks in advance

[edited by: Roolio at 5:08 pm (utc) on Oct. 23, 2007]

5:29 pm on Oct 23, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 12, 2007
posts:766
votes: 0


What state is your magic_quotes_sybase set to?

As from the notes under stripslashes -

Note: If magic_quotes_sybase is on, no backslashes are stripped off but two apostrophes are replaced by one instead.
6:15 pm on Oct 23, 2007 (gmt 0)

New User

10+ Year Member

joined:May 15, 2003
posts:28
votes: 0


Hi PHP_Chimp,

I doubt that's it, stripslashes is working with all other php-scripts on the site, only not with this one.

Thanks for helping

6:26 pm on Oct 23, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 15, 2004
posts:1867
votes: 0


$var5 = stripslashes(str_replace("_"," ",$var4));

I would try this:

$var5 = str_replace("_"," ",$var4);
$var5 = stripslashes($var5);

Habtom

6:57 pm on Oct 23, 2007 (gmt 0)

New User

10+ Year Member

joined:May 15, 2003
posts:28
votes: 0


I would try this:

$var5 = str_replace("_"," ",$var4);
$var5 = stripslashes($var5);

This doesn't work too, the slashes are still there.

9:25 pm on Oct 23, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 16, 2007
posts:477
votes: 0


what is the value of $rslt1[$j] and how do you get this variable?
the case may be that you've accidently applied the mysql_real_escape_string() to this var, which is what happened to me.
10:59 pm on Oct 23, 2007 (gmt 0)

New User

10+ Year Member

joined:May 15, 2003
posts:28
votes: 0


what is the value of $rslt1[$j] and how do you get this variable?
the case may be that you've accidently applied the mysql_real_escape_string() to this var, which is what happened to me.

I've checked the whole document and every variable that has a relation to rslt1[$j] but nowhere I could find the mysql_real_escape_string or anything other suspicious that could lead to the disfunctioning of stripslashes.

4:38 pm on Oct 24, 2007 (gmt 0)

New User

10+ Year Member

joined:May 15, 2003
posts:28
votes: 0


Noone?
5:03 pm on Oct 24, 2007 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


have you tried stripslashes being the very first thing done to $rslt1[$j][title]

all the changes you make could be making it impossible for stripslashes to work

5:15 pm on Oct 24, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 12, 2007
posts:766
votes: 0


Although this is a little desperate -
If stripslashes are working on all other scripts what is different about this one?
Is this script in an include file?
Does this use variables from an include file?
Are you using and ini_set stuff in this script?
Is this script on a different server/different area that may have different php config?

I guess that you dont need to answer the questions just check them all to see. As if stripslashes is working for something and not for other things then there must be something different in the set up or use.

Another thought - have you looked to see if there is a bug report for the version of php you are using and stripslashes? As it may be as suggested above that stripslashes is not working in combination with other functions.

Ok end of desperate attempt :) Hope some of it helps