Page 1 of 1

Help!!! Problem with list table

Posted: Thu Nov 19, 2009 12:12 pm
by Nimaro
hy everyone,

Im trying to list the personal stats of some client... for that im using this code....

Code: Select all

<?php require_once("includes/session.php");?>           
<?php require_once("includes/connection.php");?>
<?php require_once("includes/functions.php");?>
<title>Pesquisar Clientes</title>
 
<?php if(isset($_POST['submit']))
{
    $nome =($_POST['nome']);
    $executa="SHOW TABLES";
    echo "<center><font face=Verdana size=2><b>Tabelas da base de dados</b></font></center><br>";
    $query = mysql_query("SELECT * FROM pacientes WHERE nome = '".mysql_real_escape_string($nome)."'");
    echo "<table>";
 
    while ($dados=mysql_fetch_array($query))    {
        echo "<tr><td><font face=Verdana size=2 color=#333300><B>Nome 
          da tabela => $dados[0]</td></tr>";
        $executa="DESCRIBE $dados[0]";
        $aux=mysql_query($executa);
        while ($atributos=mysql_fetch_array($aux))      {
            echo "<tr><td><font face=Verdana size=1>$atributos[0]</td><td>
            <font face=Verdana size=1>| $atributos[1]</td><td>
            <font face=Verdana size=1>| $atributos[3]</td></tr>";       }
    echo "</table>";    }
}else { $nome = '';}
?>
<h1><center> Pesquisar Clientes </center></h1><br/>
 
<!--------INSERIR CLIENTES--------->
<form action="pesquisar_pacientes.php" method="post">
      <table>
          <tr><td>Nome:</td>
             <td><input type="text" name="nome" maxlength="30" value="<?php echo htmlentities($nome); ?>"/></td></tr>
          <tr><td colspan="2"><input type="submit" name="submit" value="Pesquisar" /></td></tr>
     </table>
</form>

But im having a error when i try to find some client by her name....
the error is ----> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Secretel\pesquisar_pacientes.php on line 19
Nome da tabela => 7

The code that is in line 19 is the second while...

Code: Select all

while ($atributos=mysql_fetch_array($aux))      {

Hope u can help me,

Posted: Thu Nov 19, 2009 1:09 pm
by Jonah Bron
Try printing the value of $aux. It might be returning the boolean false for some reason.

Re: Help!!! Problem with list table

Posted: Thu Nov 19, 2009 1:12 pm
by Christopher
Probably this query is failing:

Code: Select all

        $executa="DESCRIBE $dados[0]";
         $aux=mysql_query($executa);
Echo $execute to find the problem. Perhaps "DESCRIBE {$dados[0]}" would be better.

Posted: Thu Nov 19, 2009 1:33 pm
by Jonah Bron
Didn't see that :)

Try printing mysql_error() too.

Re: Help!!! Problem with list table

Posted: Thu Nov 19, 2009 2:21 pm
by Nimaro
i printed $executar adn it show = DESCRIBE 7..... 7 is the position of the name i want to print...

but then i try to echo $aux and it dosent shows nothing :/

Posted: Thu Nov 19, 2009 3:52 pm
by Jonah Bron
Echo mysql_error().