Jump to content

Warning: Mysql_Numrows() Expects Parameter 1 To Be Resource, Boolean Given In (...) On Line 62


joex

Recommended Posts

Hi guys,

 

I'm having issues that I don't know how to solve. Read about 5 topics but nothing worked... This is my code, it was working on another website, but on the new one, it isn't... Any help would be greatly appreciated! Thanks a lot for reading.

PS: Sorry if I posted anything wrong!

 

<?php

/**/

 

class BancoDados{

var $dbh;//objeto conexao

var $ultimo_sql;//ultimo sql executado

var $ultimo_erro;//ultimo erro ocorrido

var $obj_retorno;//objeto com valores retornados do bd

var $linhas;//linhas retornadas na ultima pesquisa

var $ultimo_id;//ultimo id retornado por um insert

 

function BancoDados(){

}

 

function _BancoDados(){

unset ($this);

}

 

 

function conecta(){

 

if(!$this->dbh=mysql_connect("localhost", "massim6_adm", "xxx")){

//if(!$this->dbh=mysql_connect("localhost", "root", "")){

$this->ultimo_erro='Erro na conexão com o banco de dados:' . mysql_error();

return false;

}

mysql_select_db ("massim6_loja");

//mysql_select_db ("massim6");

return true;

 

}

 

function desconecta(){

mysql_close($this->dbh);

}

 

function iniciaTransacao(){

$begin = 'begin;';

mysql_query($begin,$this->dbh);

}

 

function confirmaTransacao(){

$commit = 'commit;';

mysql_query($commit,$this->dbh);

}

 

function abortaTransacao(){

$rollback = 'rollback;';

mysql_query($rollback,$this->dbh);

}

 

function getLinhas(){

$this->linhas = mysql_numrows($this->obj_retorno);

return $this->linhas;

}

 

function getUltimoId(){

$this->ultimo_id = mysql_insert_id($this->dbh);

return $this->ultimo_id;

}

 

 

function executaSql($sql){

if (!$this->conecta()){

return false;

}

$this->ultimo_sql=$sql;

$this->obj_retorno=mysql_query($sql,$this->dbh);

if ($this->obj_retorno==false){

$this->ultimo_erro = mysql_error($this->dbh);

$this->desconecta();

return false;

}

else return true;

}

// Funções de modificação de dadas

// formato banco

function formataDataBc($data){

 

$str = split("/",$data);

$dia = $str[0];

$mes = $str[1];

$ano = $str[2];

$data = $ano.'-'.$mes.'-'.$dia;

return $data;

}

 

// Formato Brasileiro

function formataDataBr($data){

 

$str = split("-",$data);

$ano = $str[0];

$mes = $str[1];

$dia = $str[2];

$data = $dia.'/'.$mes.'/'.$ano;

return $data;

}

}//BancoDados

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.