Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/07/2012, 11:01
jimmymark
 
Fecha de Ingreso: agosto-2010
Ubicación: Lima - Perú
Mensajes: 90
Antigüedad: 13 años, 8 meses
Puntos: 2
De acuerdo error al jalar datos de BD con funciones php

*********** mi archivo index.php ***********
Código PHP:
<?php 
include("clases/conn.class.php");
$link=Conectarse();
include(
"clases/funciones.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>
<body>

<?php
$rubros
=DBreturn(Conectarse(),"miboda_productos_provee","categoria=1","order by nombre desc","");
echo 
'<ul>';
    while(
$row_rubros mysql_fetch_array($rubros))  { 
     echo
'<li>sd
             <table>
                 <tr>
                    <td>'
.$row_rubros["nombre"].'</td>
                    <td>'
.$row_rubros["direccion"].'</td>
                    <td>'
.$row_rubros["telefono"].'</td>
                    <td>'
.$row_rubros["correo"].'</td>
                 </tr>
             </table>
         </li>'
;
    }
echo 
'</ul>';
?>

</body>
</html>

***********mi archivo conn.class.php************
Código PHP:
<?php
function Conectarse()
{
    if (
$link=mysql_connect("localhost","root",""))
    {
        if (
mysql_select_db("miboda_miboda"$link)) { return $link; } else { echo "Error al seleccionar base de datos"; return false; }
    } else {
        echo 
"Error al conectarse: DB";
        return 
false;
    }
}
?>
***********mi archivo funciones.php************
Código PHP:
<?php
function DBreturn($link$xtable$xreturn_fields$xcond$xcond2)
{
    if (
$link!="" and $xtable!="" and $xreturn_fields!="")
    {
        if (
$xcond!="") { $xcond=" where ".$xcond; } else { $xcond=""; }
        if (
$DBresult=mysql_query("select ".$xreturn_fields" from ".$xtable.$xcond." ".$xcond2$link))
        {
            if (
mysql_num_rows($DBresult)>0) { return mysql_fetch_array($DBresult); } else { return false; }
        } else {
            return 
false;
        }        
    } else {
        echo 
'<p class="texto">Error al llamar función (3): falta de parámetros.</p>'; return false;
    }
}
?>

desde ayer e estado revisando el codigo pero no llego a dar con el error, me aparece el siguiente mensaje
Cita:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ajax_prueba\index.php on line 17
y es la linea del while($row_rubros = mysql_fetch_array($rubros))

alguien puede ayudarme a ver mi error, le estare muy agradecido.

Saludos foreros
__________________
"La imaginación es más importante que el conocimiento. El conocimiento es limitado, mientras que la imaginación no"