OOB problem, super stumped.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am super stumped. This works fine separately but when I put everything
together it breaks. I has an authenticate class and a sql class. However I
always get the same error.

 

SQL class.

<?php

      

      class SQL {

            public $host;

            public $user;

            public $pass;

            public $conx;

            public $db;

            public $dbname;

            public $query;

            public $result;

            public $fetchedArray;

            public $nRows;

            

            public function __construct($host,$user,$pass,$dbname = null){

                  $this->host=$host;

                  $this->user=$user;

                  $this->pass=$pass;

                  $this->conx=$this->connection($host,$user,$pass);

                  if (!is_null($dbname)){ $this->selectDb($dbname); }

            }

            

            final public function connection($host,$user,$pass){

                  $this->conx=mysql_connect($host,$user,$pass) 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_ASSOC);

                  return $this->fetchedArray;

            }

            

            final public function makeArray($query){

                  $this->curArray=mysql_fetch_array($query,MYSQL_ASSOC);

                  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 class

 

<?php

      

      class Authentication extends SQL {

            public $errorMsg;

            

            public function __construct(){echo "Auth constructed";}

            

            final public function verifyCreds ($user, $pass, $table)

            {

                  $result = $this->query("SELECT * FROM $table where
$user='$pass'");

                  

                  if ($this->numRows($this->result) == 0)

                  {

                        $this->errorMsg = "Incorrect Username/Password
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 classes

      function __autoload($class_name) {

            require_once 'includes/classes/class_' . strtolower($class_name)
. '.php';

      }

      

      // initialize Renegades Revenge database

      $database = new SQL($host,$user,$pass,"aerocor_renegade");

            

      // login

      if (isset($_GET['login']))

      {

            $auth = new
Authentication($host,$user,$pass,"aerocor_renegade");

            if
($auth->verifyCreds($_POST['username'],$_POST['password'],"players"))

            {

                  echo "logged in good!";

            }

      }

                        

?>

 

The form is just 2 fields. Username and password. I get this error.

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in /home/aerocor/public_html/rr/includes/classes/class_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/classes/class_sql.php on
line 71

 

I put some simple query and display code in the constructor for the SQL
class and it outputted from the database with no problem, that's whats
weird.

 

Any help would be great, thanks.

 

Brian


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux