Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/02/2009, 09:37
Avatar de Wilfred
Wilfred
 
Fecha de Ingreso: octubre-2008
Mensajes: 110
Antigüedad: 15 años, 6 meses
Puntos: 1
error usando variable en consulta con un while

Hola a todo,
Mi problema es que al usar una variable en una consulta no me funciona bien el script, sin embargo si lo hago sin variable si funciona bien.

aki el code :
Código:
<?php
//MySQL connect
$link = mysql_connect('localhost', 'root', 'root');
if (!$link) {
    die('Could not connect: ' . mysql_error());
    }

//Databse select
$db = mysql_select_db('savoy', $link);
if (!$db) {
    die ('error seleccionando la db : ' . mysql_error());
}

//show fields

$list_fields=  mysql_query("SHOW COLUMNS FROM jos_banner");
    
    while ($row = mysql_fetch_array($list_fields)){
     echo"$row[Field]</br>";
    
    }


?>
aqui la parte importante:
Código:
//si lo hago asi funciona
$list_fields=  mysql_query("SHOW COLUMNS FROM jos_banner");
//si lo ago usando una variable no funciona
$list_fields=  mysql_query("SHOW COLUMNS FROM '".$table."'");
$table= jos_banner;
//eso me produce el siguiente error :Warning: mysql_fetch_array(): supplied argument //is not a valid MySQL result resource in /var/www/misc/prueba.php on line 19