user911712
user911712

Reputation: 45

What is wrong with this code, it's not deleting the data?

i am importing csv file to delete the mysql database according articleno but its not deleting

if ($_FILES[csv][size] > 0) { 

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

    do { 
        if ($data[0]) { 
            $fss = '.addslashes($data[1]).';
            mysql_query("DELETE from  contacts where articleno =  $fss ");
        }
}

Upvotes: 0

Views: 55

Answers (3)

Karamazovi
Karamazovi

Reputation: 55

Because $fss is inserted in a string it doesn't have to be a string. Removing the quotes around the variable should suffice

Try checking what $fss is after setting it to 'addslashes($data[1])'. Is it the value you thought it would be?

Upvotes: 0

Littlebobbydroptables
Littlebobbydroptables

Reputation: 3731

$fss = '.addslashes($data[1]).';

Change it to

$fss = addslashes($data[1]);

because now your query looks like

DELETE from  contacts where articleno = .addslashes($data[1]).

:)

Upvotes: 1

echo_Me
echo_Me

Reputation: 37233

change this

  $fss = '.addslashes($data[1]).';

to

  $fss = addslashes($data[1]);

Upvotes: 1

Related Questions