MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 7th, 2004, 10:38 PM
rayw rayw is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 5 rayw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy php/mySQL mysql_num_rows error i don't get.

i'm trying to make a code for my mailing list script so that the admin can delete a suscriber. here's the code:

<?
// include the variables, and connect to mySQL.
include ("sqlvars.php");
include ("sqlconnect.php");
// vars from form.
$name = $_GET['name'];
$email = $_GET['email'];
// delete query
$deleteresult = mysql_query ("DELETE FROM xyz
WHERE name = '$name'
AND email = '$email'
");
// if deletion successful ...
if (mysql_num_rows($deleteresult) > 0)
{
print "successful! query deleted.";
}
// if deletion not.
elseif (mysql_num_rows($deleteresult) < 0)
{
print "unsuccessful. either the name/address does not exist, or another error has occured.";
exit;
}
?>

and I get the error "mysql_num_rows(): supplied argument is not a valid MySQL result resource in :/pathtofile."

i've used other functions to do it too, like 'mysql_affected_rows();' .. i just don't get what's wrong. other websites using this seem to work okay with it.

Reply With Quote
  #2  
Old April 8th, 2004, 07:50 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
As far as I know, you cannot use this with a DELETE query. Like you said yourself, use mysql_affected_rows() or just check if the query is executed with a simple if-statement.

Cheers,
__________________
Work to live, don't live to work

Reply With Quote
  #3  
Old April 8th, 2004, 12:52 PM
rayw rayw is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 5 rayw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
nope, it still won't work.

Reply With Quote
  #4  
Old April 8th, 2004, 03:04 PM
athlon_man athlon_man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 athlon_man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try replacing DELETE in the Query to DROP. That may or may not work. I've seen it work and sometimes not work, but just by taking a quick glance at it, I remembered seeing somewhere that the command is called DROP

Reply With Quote
  #5  
Old April 8th, 2004, 03:31 PM
rayw rayw is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 5 rayw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
no. :/ it still won't work, even with the drop. i don't think anything is wrong with the mySQL command.. thanks anyway. I think its the if statement, 'cause thats where the server says the error is.

Reply With Quote
  #6  
Old April 29th, 2004, 03:41 PM
athlon_man athlon_man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 athlon_man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry about that last suggestion, my mistake, lol. I took a look at your code, and I'm wondering where the result of the query is stated? What you would have to do is create a variable with a value that is actually giving the result of the delete query, so it might look something like this:
$result=mysql_result($deleteresult,"name");

What that should do is give you the result of the delete query, and if it's successful, it should have a value=0. So your if statement would change to something like this:

if (0==$result) {
echo "Delete Successful."
} else {
echo "Delete Not Successful."
}

That's a little one I can think of that might do it, or it might not. I'm sure there's probably 100's of solutions for it, being open source and all Hope that one works.

Reply With Quote
  #7  
Old April 29th, 2004, 04:23 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
according to the php manual, the num_rows() is used in select querys, and the affected_rows (); is used in deletion and insertion querys

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > php/mySQL mysql_num_rows error i don't get.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway