Solved

Delete statement not working

Posted on 2007-04-06
9
140 Views
Last Modified: 2007-04-06
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']);
0
Comment
Question by:pingeyeg
  • 5
  • 4
9 Comments
 
LVL 24

Expert Comment

by:glcummins
ID: 18863644
"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
 
LVL 1

Author Comment

by:pingeyeg
ID: 18863657
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
 
LVL 24

Expert Comment

by:glcummins
ID: 18863675
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 1

Author Comment

by:pingeyeg
ID: 18863773
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
 
LVL 24

Accepted Solution

by:
glcummins earned 500 total points
ID: 18863786
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
 
LVL 1

Author Comment

by:pingeyeg
ID: 18863832
Ok, I saw my error, I wasn't setting the variable correctly and it is being passed correctly, but still nothing.
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18863848
>>but still nothing

What is happening now? Does the script complete without any feedback, or are you getting an error?
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18863866
Ok, I got it.  I guess I was using the wrong function to get what I needed.  Thanks!
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18863873
Happy to help! If we can help again, let us know.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question