Warning: mysql_num_rows(): supplied argument is not a valid

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tobymac
Forum Newbie
Posts: 3
Joined: Thu Jul 21, 2011 1:40 am

Warning: mysql_num_rows(): supplied argument is not a valid

Post by tobymac »

I know it is something easy to fix. This is a "forgot password" form for my website. the error i get is Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ... on line 12. what is the problem and how can i fix it so it sends?


<?php $outputForUser = ""; if ($_POST[' ... y> </html>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Warning: mysql_num_rows(): supplied argument is not a va

Post by social_experiment »

Code: Select all

<?php
$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND email_activated='1'"); 
echo $sql;
?>
What is displayed if you print the query
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
tobymac
Forum Newbie
Posts: 3
Joined: Thu Jul 21, 2011 1:40 am

Re: Warning: mysql_num_rows(): supplied argument is not a va

Post by tobymac »

it's the same thing...
tobymac
Forum Newbie
Posts: 3
Joined: Thu Jul 21, 2011 1:40 am

Re: Warning: mysql_num_rows(): supplied argument is not a va

Post by tobymac »

Am i missing a myql form entry?
beetree
Forum Commoner
Posts: 26
Joined: Mon Jul 18, 2011 6:30 pm
Location: Peninsula

Re: Warning: mysql_num_rows(): supplied argument is not a va

Post by beetree »

Try printing the query from the PHP script. Then run the same query in MySQL manually and see if it returns any results. Faults could be:

1. Miss-typed argument names
2. Miss-typed table name
3. $email containing bad characters e.g. '

/Johan
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Warning: mysql_num_rows(): supplied argument is not a va

Post by social_experiment »

social_experiment wrote:What is displayed if you print the query
beetree wrote:Try printing the query from the PHP script.
If you print the query you will see what the query looks like when it is passed to the database, from there it will be easier to find an answer to your question. Paste the results here :)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply