Jump to content

[SOLVED] Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc


Vivid Lust

Recommended Posts

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
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.