Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not Displaying Query results.

    <?php
    echo "Establishing Connection to Host...<br>";
    $db = mysql_connect('localhost','root','') or
    die ("Can't connect to database");
    echo "Connecting to database.....<br>";
    mysql_select_db('perldesk') or
    die ("Can't select database");
    echo ("Processing Name...........<br>");
    $result=mysql_query("select name from perlDesk_users");
    while($row = mysql_fetch_array($result));{
    echo ($row["name"]);
    }
    echo "<br>";
    mysql_close($db);
    echo "Database is now Closed";
    It not displaying the information in the Select Statement on the php Page. But when I run the select statment in mysql to query the database it runs fine.
    Last edited by gkelly; 06-13-2005 at 02:59 PM. Reason: update

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You have a semi colon after your while loop that shouldn't be there.
    while($row = mysql_fetch_array($result));{

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Brandoe85
    You have a semi colon after your while loop that shouldn't be there.
    while($row = mysql_fetch_array($result));{
    Thank You, its fixed

  • #4
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You should make use of the "code" and "/code" tags provided by vBulletin. They make it a lot easier for everyone to read code that you've posted.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Brisbane, Australia
    Posts
    181
    Thanks
    1
    Thanked 0 Times in 0 Posts
    try mysql_fetch_assoc instead of mysql_fetch_array


    http://www.php.net/mysql_fetch_assoc
    -mR_eGo
    _______________________
    Programming since
    3 years old.

  • #6
    Regular Coder
    Join Date
    Apr 2005
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is the difference in mysql_fetch_assoc and mysql_fetch_array?

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    mysql_fetch_assoc will dump the results into an associative array by default, but with mysql_fetch_array you need to tell it to do that. Another option is mysql_fetch_object which return the results in an object form.


  •  

    Posting Permissions

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