Enviado em 06/04/2013 - 17:03h
Oi eu estava tentando instalar um site mas ele esta dando um seguinte erro no caso este Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/servisd/public_html/site/classes/mysql.php on line 67
<?php
class mysql{
private $usuario="servisd_serv25";
private $senha="205215488sggys18";
private $servidor="localhost";
private $bd="servisd_base21";
private $idBd=null;
public function __construct(){
$this->conect();
}
public function __destruct(){
// mysql_close($this->idBd);
}
public function conect(){
if(is_null($this->idBd)){
// echo "entro";
if(!($this->idBd = mysql_connect($this->servidor,$this->usuario,$this->senha))){
mysql_error();
return false;
}
if(!$this->bd = (mysql_select_db($this->bd,$this->idBd))){
mysql_error();
return false;
}
return true;
}
}
public function select($tabela=null,$campos=null,$where=null,$from=null){
//usa-se o array 'campos' p/ montar as colunas do select
if(is_array($campos)){
$colunas="";
$size = sizeof($campos);
$cont=0;
while($cont = mysql_fetch_object($size)){
if($cont==$size)
$colunas = $colunas . $campos[$cont];
else
$colunas = $colunas . $campos[$cont] . ",";
$cont++;
}
}
else if(empty($campos) or is_null($campos))
$colunas="*";
else
$colunas=$campos;
if(is_null($from) or empty($from))
$from ="from";
$sql = "select $colunas $from $tabela $where";
//echo $sql;
$reg = mysql_query($sql,$this->idBd);
$valores = array();
while($linha = mysql_fetch_object($reg))
$valores[] = $linha;
return $valores;
}
public function query($query){
//echo $query;
return mysql_query($query,$this->idBd) or die(mysql_error());
}
}
?>