Vivid Lust Posted February 18, 2009 Share Posted February 18, 2009 Hi guys, Could someone please help me with this error? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/onestamp/public_html/webjar/process/authMember.php on line 22 My code is as follows: <?php //db info $dbHost = "localhost"; $dbUser = "onestamp_admin"; $dbPass = "****"; $dbName = "onestamp_webjar"; //connect to mysql $connect = mysql_connect($dbHost, $dbUser, $dbPass) or die ('Error connecting to mysql'); //connect to db mysql_select_db($dbName,$connect) or die ('Error connecting to mysql') or die(mysql_error()); ?> <?php require('../includes/config.php'); if( $_POST['username'] == "" || $_POST['pass'] == "" ){ // check if form fields were filled in header('location:../login.php'); // go back to the form die(); }else{ // username and password sent from form $username=$_POST['username']; $password=$_POST['pass']; // To protect MySQL injection $user = stripslashes($username); $pass = stripslashes($password); $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $pass = md5($pass); $sql="SELECT * FROM member WHERE username='$user' and pass='$pass'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count= mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ echo( "You're in!" ); // do this if login is success }else{ // end if count is equal to 1 //header('location:../login.php'); // go back to the form } }// end else ?> Link to comment https://forums.phpfreaks.com/topic/145735-solved-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/ Share on other sites More sharing options...
Cal Posted February 18, 2009 Share Posted February 18, 2009 It's probably an error in your query replace this $result=mysql_query($sql); with this $result=mysql_query($sql) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/145735-solved-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-765147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.