Hi all am having problems with my login forms. I have written the code and has no errors, but when I run it from my browser i get
"Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 269"
I have a "MySQL Table with Members where there are fields 'ID, username,password, firstname'"
I have several pages such as "Session, process, database, form, constants";
part of the code is:
<?php
/** this is the database connections specification files
can only be changed by an administrator
*/
//connect to database
require_once("constants.php");
class MySQLDB
{
var $connection; //the mysql database connection
var $num_active_user; //number of active users viewing site
var $num_active_guests; //number of guests viewing site
var $num_members; //number of signed users
//class constructor
function MySLQDB()
{
$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());
//only query database to find out number of members when getnummembers() is called for the first time, until then
//default value is set
$this->num_members = -1;
if(TRACK_VISITORS)
{
//calculate number of users at site
$this->calcNumActiveUsers();
//calculate number of guests at site
$this->calcNumActiveGuests();
}
}
//calcnumactiveusers
function calcNumActiveUsers()
{
$q = "SELECT * FROM active_users";
$result = mysql_query($q, $this->connection);
$this->num_active_users = mysql_num_rows($result);
}
//calcactiveguests
function calcNumActiveGuests()
{
$q = "SELECT * FROM active_guests";
$result = mysql_query($q, $this->connection);
$this->num_active_guests = mysql_num_rows($result);
}
//addactiveuser
function addActiveUser($username, $time)
{
$q = "UPDATE members SET timestamp = '$time' WHERE username = '$username'";
mysql_query($q, $this->connection);
if(!TRACK_VISITORS) return;
$q = "REPLACE INTO active_users VALUES ('$username', '$time')";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
please help I have been cracking my head