Jump to content

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\E_bazzar\Login.php on line 18


Recommended Posts

<?php

 

$host="localhost";

$user="root";

$pass="4161";

$db="e_bazaar";

 

mysql_connect($host,$user,$pass);

mysql_select_db($db);

 

session_start();

 

if(isset($_POST['txt_un'])) { 

$username = $_POST['txt_un']; 

$password = $_POST['txt_pass']; 

$sql = "SELECT * FROM tbl_shop WHERE un='".$username."' AND pass'".$password."' LIMIT 1"; 

$res=mysql_query($sql);

if(mysql_num_rows($res)==1) { 

echo "You logged in successfully"; 

echo "<a href=\"home.php\"> :Continue to home page </a>"; 

exit(); 

} else { 

echo "Invalid login in details provided"; 

echo "<a href=\"login.php\"> :Back to login</a>"; 

exit(); 

 

 

}

}

 

?>

PHPFreaks.com Questions, Comments, & Suggestions

This is NOT a help forum! Do not post topics asking for help that are not related to the website.

 

If you had checked the PHP Coding Help forum, where this thread is now located, you might have seen the README: PHP Resources & FAQs sticky which has

6. mysql* expects parameter 1 to be resource, boolean given

 

This means your query failed, for some reason or another. Remove any error suppressing (@), make sure you have error displaying enabled, and output mysqli_error to see specific information about your error!

Two things you need to do:

 

1. Always ue some kind of error reporting. Good practice would be to use:

$res=mysql_query($sql) or die (mysql_error());

 

That will tell you when you have an error in you're query!

 

2. Problem you are haveing is with you're SQL query. It need's t be like this:

$sql = "SELECT * FROM tbl_shop WHERE un='".$username."' AND pass='".$password."' LIMIT 1";

 

You are missing = after pass!

1. Always ue some kind of error reporting. Good practice would be to use:

$res=mysql_query($sql) or die (mysql_error());

 

That will tell you when you have an error in you're query!

While developing. Never let that get onto a live site.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.