Jump to content

mysql_num_rows(): supplied argument is not a valid MySQL result resource


blueman378

Recommended Posts

hi guys, well im copying/modifying a login system tutorial but now im getting this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Matthew\My Documents\Web\webspirited\login\login.functions.php on line 42

Incorrect Login information !

index.php:

<?php
include("../database.php");
include("login.php");

 

login.php:

<?php
if (!isLoggedIn())
{
    // user is not logged in.
    if (isset($_POST['cmdlogin']))
    {
        // retrieve the username and password sent from login form & check the login.
        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_userbox();
        } else
        {
            echo "Incorrect Login information !";
            show_loginform();
        }
    } else
    {
        // User is not logged in and has not pressed the login button
        // so we show him the loginform
        show_loginform();
    }

} else
{
    // The user is already loggedin, so we show the userbox.
    show_userbox();
}
?>

database.php:

<?
session_start();
$seed="0dAfghRqSTgx"; // the seed for the passwords
$domain =  "SITE_Domain"; // the domain name without
require_once ("functions.php");
/**
* Database.php
* 
* The Database class is meant to simplify the task of accessing
* information from the website's database.
*/
include("constants.php");
      
class MySQLDB
{
   var $connection;         //The MySQL database connection
   var $num_active_users;   //Number of active users viewing site
   var $num_active_guests;  //Number of active guests viewing site
   var $num_members;        //Number of signed-up users
   /* Note: call getNumMembers() to access $num_members! */

   /* Class constructor */
   function MySQLDB(){
      /* Make connection to database */
      $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
      mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
   }

  /* These functions are self explanatory, no need for comments */
   

   
   /**
    * query - Performs the given query on the database and
    * returns the result, which may be false, true or a
    * resource identifier.
    */
   function query($query){
      return mysql_query($query, $this->connection);
   }
};

/* Create database connection */
$database = new MySQLDB;

?>

 

functions.php:

<?php
require_once("mail.functions.php");
require_once("user.functions.php");
require_once("display.functions.php");
require_once("login.functions.php");
require_once("validation.functions.php");


function generate_code($length = 10)
{

    if ($length <= 0)
    {
        return false;
    }

    $code = "";
    $chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
    srand((double)microtime() * 1000000);
    for ($i = 0; $i < $length; $i++)
    {
        $code = $code . substr($chars, rand() % strlen($chars), 1);
    }
    return $code;

}

?>

 

if you need any other pages jsut ask cheers

 

 

 

 

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.