Results 1 to 2 of 2

Thread: Warning: mysql_fetch_array() expects parameter 1...

  1. #1
    Join Date
    Sep 2010
    Posts
    33

    Warning: mysql_fetch_array() expects parameter 1...

    i try to create a dinamique table but its not working this is the error :
    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in .... ligne 7
    here is the code :
    Code:
    <?php
    $connection=mysql_connect("localhost","root","");
    $val=$_GET['id'];
    mysql_select_db("test_base2");
    $requete = "SELECT * FROM `nature` WHERE id=$val";
    $select=mysql_query($requete);
    $row = mysql_fetch_array($select);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Tableau</title>
    </head>
    
    <body>
    <p>Afichage de l'image :<?php echo $row['name'];?></p>
    
    <table border="1" cellspacing="0" cellpadding="5">
      <tr>
        <td>Nom</td>
        <td><?php echo $row['name']; ?></td>
      </tr>
      <tr>
        <td>Place</td>
        <td><?php echo $row['place']; ?></td>
      </tr>
      <tr>
        <td>Photo</td>
        <td><img src="<?php echo $row['photo'];?>"/></td>
      </tr>
    </table>
    
    </body>
    </html>
    thanks

  2. #2
    Join Date
    Apr 2011
    Posts
    36
    Perhaps there isn't "id=a_number" in URL adress.
    Try this:
    PHP Code:
    <?php
    if(isset($_GET['id'])) {
    $connection=mysql_connect("localhost","root","");
    $val=$_GET['id'];
    mysql_select_db("test_base2");
    $requete "SELECT * FROM `nature` WHERE id=$val";
    $select=mysql_query($requete$connection);
    $row mysql_fetch_array($select);
    }
    else { 
    $row = array('name'=>'''place'=>'''photo'=>'') }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Tableau</title>
    </head>

    <body>
    <p>Afichage de l'image :<?php echo $row['name'];?></p>

    <table border="1" cellspacing="0" cellpadding="5">
      <tr>
        <td>Nom</td>
        <td><?php echo $row['name']; ?></td>
      </tr>
      <tr>
        <td>Place</td>
        <td><?php echo $row['place']; ?></td>
      </tr>
      <tr>
        <td>Photo</td>
        <td><img src="<?php echo $row['photo'];?>"/></td>
      </tr>
    </table>

    </body>
    </html>

Similar Threads

  1. fwrite() expects.... help???
    By Thadeus in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 03 Oct 2010, 08:58 AM
  2. fwrite() expects.... help???
    By Thadeus in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 03 Oct 2010, 08:54 AM
  3. 'Wmode transparent' parameter being buggy in IE. Help?
    By Kivex in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 03 Sep 2007, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •