Solved

Delete statement not working

Posted on 2007-04-06
9
139 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 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