|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
nope, it still won't work.
|
|
#4
|
|||
|
|||
|
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
|
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||
|
|||
|
according to the php manual, the num_rows() is used in select querys, and the affected_rows (); is used in deletion and insertion querys
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > php/mySQL mysql_num_rows error i don't get. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|