Jump to content

[SOLVED] stripping back slashes


Hardwarez

Recommended Posts

I have used mysql_real_escape_string() on all data that is input and stored in my db. 

 

I am using this; in a edit form.

<input type="text" size="25" MAXLENGTH="100" name="client'.$i.'" value="';
$client=$row['client'];
$client=stripslashes($client);
echo $client . '"' . $j . '>

 

Stripslashes() seems to not work.  The out put goes to the first \ and stops; showing the first back slash.

 

Ie If the client name is

Mr "Big"
.  Then the output is
Mr \

 

Link to comment
Share on other sites

try this function

 

<?php

function no_slashes($array)
    {
        foreach($array as $key=>$value)
            {
                if(is_array($value))
                    {
                        $value=no_slashes($value);
                        $array_temp[$key]=$value;                        
                    }
                else
                    {
                        $array_temp[$key]=stripslashes($value);
                    }
            }        
        return $array_temp;    
    } 

?>

Link to comment
Share on other sites

The reason why its needed: You enclose the value of your text box in double quotes, yet your value contains a double quote. So, the browser gets confused. Is it the value supposed to terminate with the first double quote it comes across? That is what it does - it doesn't 'nest' the double quotes - afterall, what would happen if the value contained a single double quote.

 

Therefore, we use the html character codes for the quotes inside things like values of elements.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.