Jump to content

[SOLVED] Remove slashes from (double and single quotes)


Dat

Recommended Posts

I'm new to this forum, but anyway. I have this variable with slashes using mysql_real_escape_string ()

I want to remove the slashes away from the variable without removing the \r\n ect.

 

$title = mysql_real_escape_string( $_POST['title'] );

 

In the variable that is currently being inputed: Miki Koishikawa\\\'s ordinary life...

Input in the database (as you may already know): Miki Koishikawa\'s ordinary life...

 

As you can see what is left is the \'s

 

I can't use stripslashes () because that would remove the \ from \r\n and that would leave me with rn.

 

Help? ???

Link to comment
Share on other sites

It's very odd that you have \r and \n literally in your database strings.  How did this happen?

 

Also, there is no need to store the backslash in the database.  It looks like you have 2 levels of escaping there when you only need 1.

 

I suspect that what you need is this:

 

$title = mysql_real_escape_string(stripslashes($_POST['title']));

 

Then your input will not have the extra backslashes in the first place.

Link to comment
Share on other sites

I got it...

function escape_data ($data) {
        global $dbc; // Need the connection
        if (ini_get('magic_quotes_gpc')) {
            $data = stripslashes($data);
        }
        return mysql_real_escape_string(trim($data), $dbc);
    }  

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.