Jump to content

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

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.