Welcome to WebmasterWorld Guest from 50.19.34.234

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Problem removing slashes with stripslashes

php stripslashes function not working

     

Roolio

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

10+ Year Member



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]

PHP_Chimp

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

WebmasterWorld Senior Member 5+ Year Member



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.

Roolio

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

10+ Year Member



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

Habtom

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

WebmasterWorld Senior Member 10+ Year Member



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

I would try this:

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

Habtom

Roolio

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

10+ Year Member



I would try this:

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

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

d40sithui

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

5+ Year Member



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.

Roolio

10:59 pm on Oct 23, 2007 (gmt 0)

10+ Year Member



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.

Roolio

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

10+ Year Member



Noone?

jatar_k

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

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



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

PHP_Chimp

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

WebmasterWorld Senior Member 5+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month