homepage Welcome to WebmasterWorld Guest from 54.227.171.163
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem removing slashes with stripslashes
php stripslashes function not working
Roolio

10+ Year Member



 
Msg#: 3485191 posted 5:04 pm on Oct 23, 2007 (gmt 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]

 

PHP_Chimp

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3485191 posted 5:29 pm on Oct 23, 2007 (gmt 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.

Roolio

10+ Year Member



 
Msg#: 3485191 posted 6:15 pm on Oct 23, 2007 (gmt 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

Habtom

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3485191 posted 6:26 pm on Oct 23, 2007 (gmt 0)

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

I would try this:

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

Habtom

Roolio

10+ Year Member



 
Msg#: 3485191 posted 6:57 pm on Oct 23, 2007 (gmt 0)

I would try this:

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

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

d40sithui

5+ Year Member



 
Msg#: 3485191 posted 9:25 pm on Oct 23, 2007 (gmt 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.

Roolio

10+ Year Member



 
Msg#: 3485191 posted 10:59 pm on Oct 23, 2007 (gmt 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.

Roolio

10+ Year Member



 
Msg#: 3485191 posted 4:38 pm on Oct 24, 2007 (gmt 0)

Noone?

jatar_k

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



 
Msg#: 3485191 posted 5:03 pm on Oct 24, 2007 (gmt 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

PHP_Chimp

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3485191 posted 5:15 pm on Oct 24, 2007 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved