Delete statement not working

This SQL statement is removing the selected provider from the db.  Can one of you tell me what is wrong?

$strSQL_Delete = mysql_query("DELETE FROM tblAdspace WHERE providerID =" . $_GET['providerID']);
LVL 1
pingeyegAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
glcumminsConnect With a Mentor Commented:
Either the field is not being passed, or it is being passed with an empty value. You might want to load the previous page in your browser and then view the HTML source  to ensure that a value is being set in that hidden field.
0
 
glcumminsCommented:
"This SQL statement is removing the selected provider from the db"

It looks like a delete statement, so I assume it is performing as expected. What result were you expecting?
0
 
pingeyegAuthor Commented:
It's no deleting the provider from the db.  I keep getting the confirmation message, but when I look into the database, that user is still there.  I'm wondering if it has to do with something else on the page.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
glcumminsCommented:
Try this modifcation to get a little more error reporting:

<?php

if (isset($_GET['providerID']) && !empty($_GET['providerID']))
{
      $sqlDelete = "DELETE FROM tblAdspace WHERE providerID =" . $_GET['providerID'];

      $strSQL_Delete = mysql_query($sqlDelete) or die("An error was encountered while performing the following query: $sqlDelete.<br />The MySQL error was: " . mysql_error());

      if (!mysql_affected_rows())
      {
            die("No matching records were found for providerID=" . $_GET['providerID']);
      }
}
else
{
      die("Please provide a providerID.");
}

?>
0
 
pingeyegAuthor Commented:
I got "Please provide a providerID." with your statement.  Does that mean the providerID is not being passed from the prior page, because I have a hidden field there to send over to this page?
0
 
pingeyegAuthor Commented:
Ok, I saw my error, I wasn't setting the variable correctly and it is being passed correctly, but still nothing.
0
 
glcumminsCommented:
>>but still nothing

What is happening now? Does the script complete without any feedback, or are you getting an error?
0
 
pingeyegAuthor Commented:
Ok, I got it.  I guess I was using the wrong function to get what I needed.  Thanks!
0
 
glcumminsCommented:
Happy to help! If we can help again, let us know.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.