Solved

Delete statement not working

Posted on 2007-04-06
9
142 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

626 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