when i try to run this code :

```
<?php
$str = "Patty O'Furniture";
if(get_magic_quotes_gpc())
    echo stripslashes($str);
?>

```

the output is `Patty O'Furniture` but when i try to run this code(upload data into database table)

```
<?php
if ($_FILES[csv][size] > 0) {

    //get the csv file
    $file = $_FILES[csv][tmp_name];
    $handle = fopen($file,"r");

    //loop through the csv file and insert into database
    do {
        if ($data[0]) {
            if(get_magic_quotes_gpc())
            mysql_query("INSERT INTO sms_recipient (store_id, recipient_name, recipient_phone) VALUES
                (
                    '".$login_id."',
                    '".stripslashes($data[0])."',
                    '".stripslashes($data[1])."'
                )
            ");
        }
    } while ($data = fgetcsv($handle,1000,",","'"));
    //
}
?>

```

the output only `Patty O` . (see screenshot)

![enter image description here](https://i.stack.imgur.com/zEjQu.jpg)

i'm not sure why when i try to save data into database using function `stripslashes` it's not working.
['https://Stackoverflow.com/questions/12851933', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1530536/']
Because you're undoing what [magic\_quotes](http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc) is trying to do.

> 
> When magic\_quotes are on, all ' (single-quote), " (double quote), \
>  (backslash) and NUL's are escaped with a backslash automatically.
> 
> 
> 

So you're removing the backslashes via `stripslashes` that are being added, and shorting the query when it hits the `'` in `O'Furniture`
use [`mysql_real_escape_string()`](http://php.net/manual/en/function.mysql-real-escape-string.php) function instead of `stripslashes()`

or 

Try to avoid `mysql_*` functions, Try to use [`mysqli`](http://www.php.net/manual/en/book.mysqli.php) or `PDO`