Hi.. im sortof a newB so bare with me.... I'm using PEAR DB within a class I'm writing but I'm getting a fatal error saying that fecthrow() is not a defined function. Now I know Pear DB works and is installed etc. becuase I have used it succesfully on my server before.. I just never tried using it within a class.. here is the code in the class file:
<?php
/************************
* CLASS.SESSION.PHP
* Handles user login.
************************/
require_once("DB.php");
class session {
var $_strUserName;
var $_strUserPass;
var $_objConn;
var $_objMail;
// Class constructor...
function session($name=' ',$pass=' ') {
$this->_objConn =& DB::connect(DSN);
if($_strUserName == ' ') {
// Ensures a username was submitted...
$this->_error("No user name was specified.");
return FALSE;
} else {
$this->_strUserName = $name;
$this->_strUserPass = $pass;
$this->_authenticate();
}
}
// Authenticates the user...
function _authenticate() {
$sql = "SELECT admin_id,admin_pass FROM administrators WHERE admin_name=" . $this->_strUserName;
echo $sql;
$objRS = $this->_objConn->query($sql);
$objRow = $objRS->fetchRow();
if($objRS->numRows() < 1) {
$this->_error("The user name you entered does not exist.");
return FALSE;
} elseif($objRS['admin_pass'] != $this->_strUserPass) {
$this->_error("The password you entered is incorrect.");
return FALSE;
} else {
echo "<p><strong>CONGRATULATIONS!</strong><br/>You have successfully logged into the site as: " . $this->_strUserName . "</p>";
}
}
// Generates an error...
function _error($strMessage) {
echo "<p><strong class=\"error\">ERROR you could no be logged:</strong><br>";
echo $strMessage;
}
}
?>
And here is how the code is called and the class is called on the main page.
require_once("../_lib/config.php");
require_once("../_lib/private/class.session.php");
if($_POST) {
$objSession = new session($_POST["username"],$_POST["userpass"]);
}
This is the exact error im getting:
Fatal error: Call to undefined function: fetchrow() in /home/notjusta/www/www/_lib/private/class.session.php on line 36