Foros del Web » Programando para Internet » PHP »

Ayuda porfavor,, esta bien esto?

Estas en el tema de Ayuda porfavor,, esta bien esto? en el foro de PHP en Foros del Web. Me gustaria que me revisaran este codigo, algo estoy haciendo mal... en el error me via esto: Warning: mysql_fetch_array(): supplied argument is not a valid ...
  #1 (permalink)  
Antiguo 17/05/2003, 16:44
 
Fecha de Ingreso: enero-2002
Mensajes: 106
Antigüedad: 22 años, 2 meses
Puntos: 0
Ayuda porfavor,, esta bien esto?

Me gustaria que me revisaran este codigo, algo estoy haciendo mal... en el error me via esto:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bol/public_html/categorias.php on line 9


<?php
require ("conn.php");

//tablas
$sContent = "";
$sContent = $sContent . "<table border=\"0\" width=\"100%\">";

$oRS = mysql_query( "SELECT * FROM CatLigas ORDER BY Id" );
while ( $row=mysql_fetch_array($oRS) )
{
$Id =$row["id"];
$Ligas =$row["ligas"];

$sContent = $sContent . "<tr>";
$sContent = $sContent . "<td width=\"100%\">$Id</td>";
$sContent = $sContent . "</tr>";
$sContent = $sContent . "<tr>";
$sContent = $sContent . "<td width=\"100%\">$Ligas</td>";
$sContent = $sContent . "</tr>";
}

$sContent = $sContent . "</table><br>";
?>
__________________
Jherrera.NET
  #2 (permalink)  
Antiguo 17/05/2003, 17:35
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Usa el "mysql_error()" para detectar errores de conexión a tu BD o de SQL ..

A simple vista (sin ver que hace "conn.php") "parece" que no has seleccionado la BD donde vas a hacer tus consultas ...

$oRS = mysql_query( "SELECT * FROM CatLigas ORDER BY Id" ) or die (msyql_error());

(usa esa estructura: or die (mysql_error()); en todas las funciones mysql_xxxx() que uses para detectar errores).

Más información en el manual de PHP sección funciones de Mysql:

www.php.net/manual/es

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
  #3 (permalink)  
Antiguo 19/05/2003, 09:46
 
Fecha de Ingreso: enero-2002
Mensajes: 106
Antigüedad: 22 años, 2 meses
Puntos: 0
Hola este es el archivo CONN.PHP

<?
$Conexion = mysql_connect("localhost","bol_ligas","bol");
mysql_select_db("bol_satelite");
?>

Anexo de nuevo el script-..

categorias.php

<?php
require ("conn.php");

//Show the latest
$sContent = "";
$sContent = $sContent . "<table border=\"0\" width=\"100%\">";

$oRS = mysql_query( "SELECT * FROM CatLigas ORDER BY Id" );
while ( $row=mysql_fetch_array($oRS) )
{
$Id =$row["id"];
$Ligas =$row["ligas"];

$sContent = $sContent . "<tr>";
$sContent = $sContent . "<td width=\"100%\">$Id</td>";
$sContent = $sContent . "</tr>";
$sContent = $sContent . "<tr>";
$sContent = $sContent . "<td width=\"100%\">$Ligas</td>";
$sContent = $sContent . "</tr>";
}

$sContent = $sContent . "</table><br>";
?>

gracias.. les agradeceria si me pueden decir donde esta el error.....
__________________
Jherrera.NET
  #4 (permalink)  
Antiguo 19/05/2003, 09:57
Avatar de Cain  
Fecha de Ingreso: enero-2002
Ubicación: Catalunya
Mensajes: 6.459
Antigüedad: 22 años, 3 meses
Puntos: 17
Cambia esto:

$oRS = mysql_query( "SELECT * FROM CatLigas ORDER BY Id" );

Por esto:

$oRS = mysql_query( "SELECT * FROM CatLigas ORDER BY Id" ) or die(mysql_error());
__________________
M a l d i t o F r i k i
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:11.