Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/10/2006, 08:23
jorgivaz
 
Fecha de Ingreso: junio-2005
Mensajes: 343
Antigüedad: 18 años, 11 meses
Puntos: 10
Ya solucione este problema, pero mira lo que me pasa ahora:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in d:\servidor\www\proyecto\web\inc\TabTgu.php on line 20

No se xo no me caigo en donde esta el error.

Código PHP:
class TabTgu {
    var 
$tgu_id;
    var 
$tgu_nombre;
    var 
$tgu_estado;

    function 
TabTgu(){}
    function 
setTguId($var){$this->tgu_id=$var;}
    function 
setTguNombre($var){$this->tgu_nombre=$var;}
    function 
setTguEstado($var){$this->tgu_estado=$var;}
    function 
getTguEstado(){return $this->tgu_estado;}
    function 
getTguNombre(){return $this->tgu_nombre;}
    function 
getTguId(){return $this->tgu_id;}
    function 
insert($MySQL){        $sql "INSERT INTO tab_tgu VALUES (null,'".$this->tgu_nombre."','".$this->tgu_estado."');";        $res $MySQL->query($sql);    }
    function 
delete($MySQL){        $sql "DELETE FROM tab_tgu WHERE tgu_id = '".$this->tgu_id."'";        $res $MySQL->query($sql);    }
    function 
update($MySQL){        $sql "UPDATE FROM tab_tgu SET tgu_nombre = '".$this->tgu_nombre."' tgu_estado = '".$this->tgu_estado."' WHERE tgu_id = '".$this->tgu_id."';";    }
}
class 
TabTguUtil {
    function 
cargaTgu($res){
        
$row mysql_fetch_assoc($res); //LINEA 20 !!!!
        
$res = new TabTgu();
        
$res->setTguId($row['tgu_id']);
        
$res->setTguNombre($row['tgu_nombre']);
        
$res->setTguEstado($row['tgu_estado']);
        return 
$res;
    }
    function 
cargaTgus($res){
        
$reg = array();
        
$registros mysql_num_rows($res);
        for (
$i=0;$i<=$registros-1;$i++){
            
$reg[$i]=$this->cargaTgu($res);
        }
        return 
$reg;
    }
    function 
getTabTguByNombre($MySQL,$var){
        
$sql "SELECT * FROM tab_tgu WHERE tgu_nombre = '".$var."'";
        
$res $MySQL->query($sql);
        return 
$this->cargaTgu($res);
    }
    function 
getTabTguByEstado($MySQL,$var){
        
$sql "SELECT * FROM tab_tgu WHERE tgu_estado = '".$var."'";
        
$res $MySQL->query($sql);
        return 
$this->cargaTgus($res);
    }

Y aquí donde lo uso:

Código PHP:
include('inc/MySQL.php');
include(
'inc/TabTgu.php');

$conn = new MySQL("localhost","root","","test");
$tabGen = new TabTgu();
$tabGenUtil = new TabTguUtil();

$tabGen->setTguNombre("prueba");
$tabGen->setTguEstado("1");
$tabGen->insert($conn);

$res $tabGenUtil->getTabTguByNombre($conn,"prueba");
echo 
$res->getTguNombre(); 
Estoy a la espera, gracias.