php form results are not resulting in anything, please help

Discussion in 'Programming' started by buzzby1971, Sep 30, 2008.

  1. #1
    hi there ppl. i have this piece of code as i would like to get the data out of the database.
    
    <?php
    $dbhost = 'localhost';
    $dbuser = '###';
    $dbpass = '###';
    $dbname = 'formresults';
    $connection = mysql_connect($dbhost, $dbpass, $dbuser) or die(mysql_error());
    $result = "select * from formflymetothemoon";
    $row = mysql_query($result);
    ?>
    
    PHP:
    thing is this does not return anything
     <div class='namewidth'><?php echo $row['name']; ?></div>
    PHP:
    what am i idoing wrong here?
    when i try to use a while loop i get an error message
    <?php
    while($row = mysql_fetch_row($result))
    {
    echo "<div class='namewidth'>";
    echo $row['name'];
    echo "</div>";
    }
    ?>
    
    PHP:
    this is the error i get:
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\wamp\www\formreview.php on line 105
    PHP:
    do i need to have this located anywhere?
    <?php echo $row['id']?>
    PHP:

     
    buzzby1971, Sep 30, 2008 IP
  2. buzzby1971

    buzzby1971 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i figured it out,

    i forgot to put in the mysql_select_db parameter

    DOH!!
     
    buzzby1971, Sep 30, 2008 IP