Código PHP:
class connection{
private $hostname_oConn ;
public $database_oConn ;
private $username_oConn ;
private $password_oConn ;
public $totalRows;
public $oConn;
public $resultArray = array();
private $queryVar;
public $resultado;
function __construct() {
$this->fillVars();
session_start();
}
private function fillVars(){
//hacerlo luego para fichero de configuracion
$this->hostname_oConn = "tao";
$this->database_oConn = "tao";
$this->username_oConn = "adm";
$this->password_oConn = "adm";
$this->totalRows = 0;
}
private function fetchArray($query){
unset($this->resultArray);
$this->resultado = mysql_query($query, $this->oConn) or die(mysql_error());
while ($fila = @mysql_fetch_array($this->resultado, MYSQL_ASSOC)){
$this->resultArray[] = $fila;
}
}
private function query($query){
$this->queryVar = $query;
$this->oConn = mysql_pconnect($this->hostname_oConn, $this->username_oConn, $this->password_oConn) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($this->database_oConn, $this->oConn);
$this->fetchArray($this->queryVar);
$this->totalRows = $this->totalRows();
mysql_close($this->oConn);
return $this->resultArray;
}
private function totalRows (){
return @mysql_num_rows($this->resultado);
}
private function sanitize($theValue, $theType){
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue,$this->resultado) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
/***********************************************************************************/
/***********************************************************************************/
/***************** COMIENZAN QUERIES ESPECIFICAS PARA EL FRONT *********************/
public function reportissue($nombre,$direccion,$telefono,$email,$averia,$tarjeta){
$sql = sprintf("INSERT INTO issues (nombre, direccion, telefono, email, averia,tarjeta_id) VALUES (%s, %s, %s, %s, %s, %s)",$nombre,$direccion,$telefono,$email,$averia,$tarjeta);
return $this->query($sql);
}
/***********************************************************************************/
/***********************************************************************************/
/***************** COMIENZAN QUERIES ESPECIFICAS PARA LA ADMON *********************/
public function loggedin(){
if (isset($_SESSION['acv2_loggedin']) && ($_SESSION['acv2_loggedin']))
return true;
else
return false;
}
public function checklogin($login, $pass){
$login = $this->sanitize($login,'text');
$pass = $this->sanitize($pass,'text');
$this->query("SELECT * FROM users WHERE login=$login AND pass=$pass");
echo $this->query;
if ($this->totalRows()>0) {
$_SESSION['acv2_user'] = $login;
$_SESSION['acv2_loggedin'] = 1;
return true;
}
else
return false;
}
}
Código PHP:
require_once('caminoalaclase.php');
$issue = new connection();
if (isset($_POST['actionForm'])){
if ($issue->checklogin($_POST['user'],$_POST['pass']))
header ("Location: content.php");
}?>
Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /caminoalaclase.php on line 50
Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in //caminoalaclase.php on line 50
que estoy hacuiendo mal en mi clase o que estoy haciendo bien nada mas.