1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Showing Results Of A Query Through Php Script

Discussion in 'PHP' started by progfrog, Dec 9, 2008.

  1. #1
    hI!
    SEMrush
    I do not know what is wrong with this code- because i don't get the results on screen as i wrote in the code:


    
    $rt=mysql_query("SELECT name FROM students"); 
    if(!$rt)
    echo "ERROR: error occured in MySQL query.";  // if any error is there that will be printed to the
    else
    {
    echo "connected successfully to query"; 
    while ($row=mysql_fetch_array($rt))
    {
    echo "name: {$row['name'] }".
    }
    }
    mysql_close($mysql_link); 
    ?>
    
    Need your help
    
    Progfrog
    
    
    
    Code (markup):
     
    progfrog, Dec 9, 2008 IP
    SEMrush
  2. crivion

    crivion Well-Known Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    160
    Digital Goods:
    3
    #2
    try like this
    $rt=mysql_query("SELECT name FROM students");
    if(!$rt)
    echo "ERROR: error occured in MySQL query."; // if any error is there that will be printed to the
    else
    {
    echo "connected successfully to query";
    while ($row=mysql_fetch_array($rt))
    {
    echo "name: {$row['name'] }";
    }
    }
    mysql_close($mysql_link);
    ?>
     
    crivion, Dec 9, 2008 IP
  3. kapinder

    kapinder Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Change the below code
    echo "name: {$row['name'] }".

    to
    echo "name: {$row['name'] }";
     
    kapinder, Dec 9, 2008 IP
  4. octalsystems

    octalsystems Active Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    85
    Digital Goods:
    1
    #4
    change these lines and hopefully it ill work

    $rt=mysql_query("SELECT name FROM students"); => $rt=mysql_query("SELECT `name` FROM students");
    echo "name: {$row['name'] }"; => echo "name: {$row[name] }";
     
    octalsystems, Dec 9, 2008 IP