hi im a newbie at this but im getting a error message that says:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pickurau/public_html/classes/Lib/Query.php on line 27
and line 27 starts with the if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1)
return false;
does anyone know how can i fix this error?
heres the script code:
<?php
class Lib_Query extends Lib_DbConnect
{
var $rs;
var $totrows;
var $records;
/**
* Enter description here...
*
* @param string $sql
* @param array $fields
* @return boolean
*/
function executeQuery($sql, $fields = array())
{
//echo $sql,"<br/>";
if(substr_count($sql,'#')!=count($fields))
return false;
if(count($fields)>0)
$sql = $this->makeQuery($sql,$fields); // Security::makeQuery();
$i=0;
$this->rs = mysql_query($sql);
if(!mysql_affected_rows() || mysql_num_rows($this->rs) < 1)
return false;
else
{
$this->totrows = mysql_num_rows($this->rs);
while($fetch = mysql_fetch_array($this->rs))
{
$this->records[$i] = $fetch;
$i++;
}
for($i=0;$i<count($this->records);$i++)
{
foreach ($this->records[$i] as $key=>$item)
{
if(is_numeric($key))
unset($this->records[$i][$key]);
}
}
return true;
}
}
/**
* @param string $sql
* @return boolean
*/
function updateQuery($sql, $fields=array())
{
if(substr_count($sql,'#')!=count($fields))
return false;
if(count($fields)>0)
$sql = $this->makeQuery($sql,$fields); // Security::makeQuery();
$this->rs = mysql_query($sql);
if(!$this->rs)
return false;
else
return true;
}
}
?>