Im totally confised by this error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\le\login.php on line 10
Can any one help me? I'm new in php
Code :
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost", "root", "") or die("Could'nt Connect");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
mysql_select_db("shit") or die("cant find db");
$numrows = mysql_num_rows($query);
echo $numrows;
} else
die("please enter username and a password");
?>
I suggest you using mysqli to interact with db. mysql_query is deprecated. See documentation here: http://php.net/manual/en/function.mysql-query.php
To connect with DB in mysqli you can do:
$DBhost = "localhost";
$DBuser = "your-user";
$DBpass = "your-password";
$DBName = "your-db-name";
// Create connection
$mysqli = new mysqli($DBhost, $DBuser, $DBpass, $DBName);
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments