i am having this error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jinii/public_html/beta/includes/db.class.php on line 79
db.class.php contains this code:
<?
class Db
{
function RemoveDoubleQoute($content) { $content = str_replace('"',"'",$content); return $content; } //var $new_article_id;
//*****Function to remove Apostrophy from a string************
function RemoveApostophy($content)
{
$content = str_replace("'","`",$content);
return $content; } //var $new_article_id; /** * Funciton Name: Constructor * Parameters: No Parameters */ var $query;
//******************************************** RECORD SET *************************************
function record_set($table, $condition, $sort_field, $order_by, $limit, $fields = '', $inner_join='', $which='limit')
{
$fields = explode(',',$fields);
$string = "";
for ($i = 0; $i < count($fields); $i++) {
$string .= $fields[$i] . ",";
}
$string = $this->RemoveApostophy(substr($string ,0,-1));// $values .= "$k='".$this->RemoveApostophy($v)."',";
if ($condition != ''){ $condition = ' where '.$condition. ' ' ; } if ($sort_field != ''){ $sort_field = ' order by '.$sort_field. ' ' . $order_by.' ' ; } if ($limit != ''){ $limit = ' limit '.$limit. ' ' ; } if ($inner_join != ''){ $inner_join = ' Inner Join '.$inner_join. ' ' ; } $rocord_set = array(); if ($which == 'limit'){ $q = "select $string from ".PREFIX."$table $condition $inner_join $sort_field $limit"; $record_set_normal = mysql_query($q); $record_set['limit'] = $record_set_normal; }elseif($which == 'total'){ $q = "select $string from ".PREFIX."$table $condition $inner_join $sort_field"; $record_set_total = mysql_query($q); $record_set['total'] = $record_set_total; }else{ $q = "select $string from ".PREFIX."$table $condition $inner_join $sort_field $limit"; $record_set_normal = mysql_query($q); $q = "select $string from ".PREFIX."$table $condition $inner_join $sort_field"; $record_set_total = mysql_query($q); $record_set['limit'] = $record_set_normal; $record_set['total'] = $record_set_total; } return $record_set; }
//********************************************* RETURN VALUES ******************************
function return_values($record_set)
{
if(mysql_num_rows($record_set))
{
$rows = 0;
$info=array();
$tmp_array = array();
while($fields = mysql_fetch_array($record_set))
{
$columns = mysql_num_fields($record_set);
$string = '';
for ($x=0; $x<$columns; $x++) {
$tmp_array[mysql_field_name($record_set, $x)] = $fields[$x];
$info[$rows]=$tmp_array;
}
$rows = $rows+1;
}
return $info;
}else{
return false;
}
}
//***************************************************************** Update Record *****
function update_record($table, $info, $condition) //update user any fields
{
$values = "";
foreach($info as $k=>$v)
{
if($k != 'Submit' AND $k != 'submit')
$values .= "$k=\"$v\",";
}
// $values = substr($values,0,-1); $values = $this->RemoveApostophy(substr($values ,0,-1)); $query = "UPDATE ".PREFIX."$table SET $values WHERE $condition "; if(mysql_query($query) ) return true; else return false; }
//************************************** ADD RECORD ******************************************
//function add_record($table, $fields, $values){
//
// if($fields != ''){
// $fields = explode(',',$fields);
// $string = "(";
// for ($i = 0; $i < count($fields); $i++) {
// $string .= $fields[$i] . ",";
// }
// $string = substr($string,0,-1);
// $string .= ")";
// }
// if($values != ''){
// $values = explode(',',$values);
// $data = "";
// for ($i = 0; $i < count($values); $i++) {
// $data .= "'" . $values[$i] . "',";
// }
// $data = substr($data ,0,-1);
// }
// $q = "insert into $table $string values($data)";
//
// $success = mysql_query($q);
// if($success)
// return true;
// else
// return false;
// }
function add_record($table, $info) { $param = ""; $values = ""; foreach($info as $k=>$v) { if($v != "" AND $k != 'Submit' AND $k != 'submit') { $param .= $k.','; $values .= "\"".$v."\","; } } $param = substr($param,0,-1); //$values = substr($values,0,-1); $values = $this->RemoveApostophy(substr($values ,0,-1)); $query = "insert into ".PREFIX."$table ($param) values($values)"; if(mysql_query($query) ) return true; else return false; }
//**************************************************************************** Delete Record
function delete_record($table, $condition){
$query = "DELETE FROM ".PREFIX. "$table WHERE( $condition )";
if(mysql_query($query))
return true;
else
return false;
}
//************************************* PAGINAITON ******************************************
function pagination($sql_result, $cur_page, $records_per_page, $link, $link_class, $link_text_patern = "[%s]"){
$this -> sql_result = $sql_result; $this -> sql_num_rows = @mysql_num_rows($this -> sql_result); $this -> sql_num_cols = @mysql_num_fields($this -> sql_result); $this -> link = $link; $this -> link_text_patern = $link_text_patern; $this -> cur_page = $cur_page; $this -> link_class = $link_class; $this -> records_per_page = $records_per_page; $this -> total_pages = ceil($this -> sql_num_rows / $this -> records_per_page); $this -> val_min_de_afisat = 0; $this -> val_man_de_afisat = 0;
}
function show_pagination() { if ($this -> total_pages > $this -> cur_page) { $this -> val_min_de_afisat = $this -> cur_page - ($this -> cur_page % 10); $this -> val_max_de_afisat = $this -> val_min_de_afisat + 10; if ($this -> cur_page > 9) echo ("<a href=\"" . $this -> link . ($this -> val_min_de_afisat-1) . "\" class='".$this -> link_class."'> << </a>\n"); for ($i = $this -> val_min_de_afisat; $i < min($this -> val_max_de_afisat, $this -> total_pages); $i++) { if ($this -> cur_page < $i) printf ("<a href=\"" . $this -> link . ($i) . "\" class='".$this -> link_class."'>" . $this -> link_text_patern . "</a>\n", $i+1); if ($this -> cur_page == $i) printf ("<span class='current'>". $this -> link_text_patern . "</span> \n", $i+1); if ($this -> cur_page > $i) printf ("<a href=\"" . $this -> link . ($i) . "\" class='".$this -> link_class."'>" . $this -> link_text_patern . "</a>\n", $i+1); } if ($this -> val_max_de_afisat < $this -> total_pages) printf ("<a href=\"" . $this -> link . ($i) . "\" class='".$this -> link_class."'> >> </a>\n", $i+1); }
}
}
//************************************************************* Redirect URl *************************
function url($url){
echo("<script language ='JavaScript'>\n");
echo("document.location ='$url';\n");
echo("</script>\n");
}
//************************************************************************* Alert Message ****************************
function alert($msg){
echo("<script language ='JavaScript'>\n");
echo("alert('$msg');\n");
echo("</script>\n");
}
?>
thanks in advance