| OOB problem, super stumped. -
06-02-2007, 08:55 PM
I am super stumped. This works fine separately but when I put everything
together it breaks. I has an authenticate cl*** and a sql cl***. However I
always get the same error.
SQL cl***.
<?php
cl*** SQL {
public $host;
public $user;
public $p***;
public $conx;
public $db;
public $dbname;
public $query;
public $result;
public $fetchedArray;
public $nRows;
public function __construct($host,$user,$p***,$dbname = null){
$this->host=$host;
$this->user=$user;
$this->p***=$p***;
$this->conx=$this->connection($host,$user,$p***);
if (!is_null($dbname)){ $this->selectDb($dbname); }
}
final public function connection($host,$user,$p***){
$this->conx=mysql_connect($host,$user,$p***) or
die(mysql_error());
}
final public function selectDb($db){
$this->db=mysql_select_db($db);
}
final public function query($query){
$this->result=mysql_query($query, $this->conx);
echo mysql_error();
echo $query;
return $this->result;
}
final public function fetchArray($query){
$this->result=$this->query($query);
$this->fetchedArray=mysql_fetch_array($this->result,MYSQL_***OC);
return $this->fetchedArray;
}
final public function makeArray($query){
$this->curArray=mysql_fetch_array($query,MYSQL_***OC);
return $this->curArray;
}
final public function numRows($result)
{
$this->nRows=mysql_num_rows($result);
return $this->nRows;
}
public function __destruct(){
if (isset($this->connection)){
mysql_close($this->connection); }
}
}
?>
Authenticate cl***
<?php
cl*** Authentication extends SQL {
public $errorMsg;
public function __construct(){echo "Auth constructed";}
final public function verifyCreds ($user, $p***, $table)
{
$result = $this->query("SELECT * FROM $table where
$user='$p***'");
if ($this->numRows($this->result) == 0)
{
$this->errorMsg = "Incorrect Username/P***word
Combo";
return false;
}
else
{
// debugging lines \/
echo "login good!";
// debugging lines /\
return true;
}
}
public function __destruct(){}
}
?>
Normal page.
<?php
/************************************************** **********
* common.php
*
* project: Renegades Revenge
* programmer: Brian Seymour
************************************************** **********/
// autoload cl***es
function __autoload($cl***_name) {
require_once 'includes/cl***es/cl***_' . strtolower($cl***_name)
.. '.php';
}
// initialize Renegades Revenge database
$database = new SQL($host,$user,$p***,"aerocor_renegade");
// login
if (isset($_GET['login']))
{
$auth = new
Authentication($host,$user,$p***,"aerocor_renegade ");
if
($auth->verifyCreds($_POST['username'],$_POST['p***word'],"players"))
{
echo "logged in good!";
}
}
?>
The form is just 2 fields. Username and p***word. I get this error.
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in /home/aerocor/public_html/rr/includes/cl***es/cl***_sql.php on line 52
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/aerocor/public_html/rr/includes/cl***es/cl***_sql.php on
line 71
I put some simple query and display code in the constructor for the SQL
cl*** and it outputted from the database with no problem, that's whats
weird.
Any help would be great, thanks.
Brian |