JakeSilver Posted June 18, 2008 Share Posted June 18, 2008 I am recieving the following error =( Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 71 70 $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1' LIMIT 1"); 71 $login_check = mysql_num_rows($sql); 72 $inf = mysql_fetch_object($sql); Is this due to the structure of my query? Thanks in Advanced Link to comment https://forums.phpfreaks.com/topic/110713-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/ Share on other sites More sharing options...
mmarif4u Posted June 18, 2008 Share Posted June 18, 2008 Nope,i think query is ok. may be the column name is different in mysql table. check that. Link to comment https://forums.phpfreaks.com/topic/110713-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-568018 Share on other sites More sharing options...
mark110384 Posted June 18, 2008 Share Posted June 18, 2008 Try the following $sql = "SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1' LIMIT 1"; $result = mysql_query($sql); $count = mysql_num_rows($result); if ($count == 1) { //Put what you wan't to do here } else { echo "Error! Failed to log you in."; } Link to comment https://forums.phpfreaks.com/topic/110713-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-568099 Share on other sites More sharing options...
kenrbnsn Posted June 18, 2008 Share Posted June 18, 2008 Always check to see if the query succeeds before doing any other MySQL operations: <?php $sql = "SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1' LIMIT 1"; $result = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error()); ?> If an error prints, it should give you a hint as to what is wrong. Ken Link to comment https://forums.phpfreaks.com/topic/110713-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-568107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.