hola,tengo el siguiente código que me funciona casi a la perfección,es decir yo pongo archivo.php?id=15 y funciona todo bien
<? include ("config.php");
$id = $_GET['id'];
$sql = "select * from peliculas where id=$id";
//Instrucción a ejecutarse en la bbdd.
$squery = mysql_query($sql);
//Ejecución de la instrucción
while($row = mysql_fetch_array($squery)){
//Recuperar los datos de un registro o hilera (row) y meterlo a un array
echo "<b>".$row['des']."</b>"; }
?>
el caso es que si hago abro archivo.php me da los siguientes errores:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/x/public_html/x/x.php on line 128
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/x/public_html/x/x.php on line 153
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
como podría hacer para que si entran en video.php no diera ese error?
gracias
Si funciona el código correctamente, deberías de verificar el error, en el otro archivo (/home2/x/public_html/x/x.php). Además para estar más seguros, trata de ponerle excepciones. Así:
<?
include ("config.php");
$id = $_GET['id'];
$sql = "select * from peliculas where id=".$id;
$squery = mysql_query($sql);
if (!$squery ) {
die('Invalid query: ' . mysql_error());
}
while($row = mysql_fetch_array($squery)){
echo "<b>".$row['des']."</b>";
}
?>