So I'm developing a CMS(Content Management System) from scratch because I have nothing else to do this summer. So I did the register page first so my friends can test it out. I'm now doing the login page and I get an error on top of the page which is:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
Here is my login.php
<?php
/*##############################################
# Shadowcms #
# © 2011 #
# Devbest #
# #
##############################################
*/
//Database Info
$dbhost = "localhost"; // Default is localhost
$dbname = "shadowcms"; //Database
$dbuser = "root"; // Default is root
$dbpass = "password"; //phpmyadmin password
// Connecting to database yay!
mysql_connect($dbhost, $dbuser, $dbpass) or die ("Could not connect: ". mysql_error());
mysql_select_db($dbname) or die (mysql_error());
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "SELECT * FROM users WHERE username = ’$username’ and password=’$password’";
$result = mysql_query($query);
if(mysql_num_rows($result)!= 1) {
$error = "Failed login";
include "login.htm";
}
else
{
$_SESSION['username'] = "$username";
include "me.php";
}
?>
Please help and explain it so I can learn next time if I want to make another CMS.