Help!!! Problem with list table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Nimaro
Forum Newbie
Posts: 19
Joined: Thu Nov 19, 2009 11:26 am

Help!!! Problem with list table

Post 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,
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

Try printing the value of $aux. It might be returning the boolean false for some reason.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Help!!! Problem with list table

Post 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.
(#10850)
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

Didn't see that :)

Try printing mysql_error() too.
User avatar
Nimaro
Forum Newbie
Posts: 19
Joined: Thu Nov 19, 2009 11:26 am

Re: Help!!! Problem with list table

Post 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 :/
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

Echo mysql_error().
Post Reply