Jump to content

Delete3()


RON_ron

Recommended Posts

I'm trying to delete a complete row from 3 databases. But it's not functioning. I can't see an error. Could someone help?

 

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


$sqlA="DELETE FROM showrooms WHERE salesperson = '".$sperson."'";
$result1=mysql_query($sqlA);

$sqlB="DELETE FROM supplier WHERE salesperson = '".$sperson."'";
$result2=mysql_query($sqlB);

$sqlC="DELETE FROM data WHERE salesperson = '".$sperson."'";
$result3=mysql_query($sqlC);



if($result1 && $result2 && $result3){
$login = "Success";
echo($login);
} else {
$login = "failed";
echo($login);
};

Link to comment
https://forums.phpfreaks.com/topic/271672-delete3/
Share on other sites

Define: But it's not functioning?

 

What result are you getting? What output or symptom occurred in front of you that leads you to believe it's not functioning?

 

If you are getting a 'Success' message, but the rows are not being deleted, the only thing your conditional code at the end is doing is testing if the queries ran without any errors. That doesn't mean they actually deleted anything, which would occur if the WHERE clause is FALSE (i.e. the $sperson variable is empty or doesn't match any entry in the table(s).) You would need to both test if the queries executed without any error and use mysql_affected_rows to determine if any row(s) were actually deleted before outputting a 'Success' message.

Link to comment
https://forums.phpfreaks.com/topic/271672-delete3/#findComment-1397842
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.