Solved

Delete statement not working

Posted on 2007-04-06
9
135 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now