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

 

 

 

 

Link to comment
Share on other sites

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.