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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Simple error "mysql_fetch_array(): supplied argument is not a valid MySQL..."

    Here is th link to the error: http://www.mujak.com/test/test2.php
    (The one at the very bottom)
    What I am trying to do is display all usernames & their posts.
    PHP Code:
    $result mysql_query("SELECT * FROM mybb_users LEFT JOIN mybb_posts ON (mybb_users.uid = mybb_posts.uid) ORDER BY username ASC"); 
    comes out as:

    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rootkbc1/public_html/mujak/test/test2.php on line 106

  • #2
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is the whole code:

    PHP Code:
    <?php
    $con 
    mysql_connect("mujak.com","rootkbc1_muser","******");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("rootkbc1_halo2x"$con);


    $result mysql_query("SELECT * FROM mybb_users LEFT JOIN mybb_posts ON (mybb_users.uid = mybb_posts.uid) ORDER BY username ASC");

    echo 
    "<center><table border=1 bgcolor=white>
    <tr>
    <th><h1>Username</h1></th>
    <th bgcolor=#C0CFFA><h1>Posts</h1></th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result))
      {
      echo 
    "<tr>";
      echo 
    "<td>" $row['username'] . "</td>";
      echo 
    "<td bgcolor=#C0CFFA>" $row['uid'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";

    mysql_close($con);
    ?>

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    result = mysql_query("SELECT * FROM mybb_users LEFT JOIN mybb_posts ON (mybb_users.uid = mybb_posts.uid) ORDER BY username ASC");
    Change the above to
    PHP Code:
    result mysql_query("SELECT * FROM mybb_users LEFT JOIN mybb_posts ON (mybb_users.uid = mybb_posts.uid) 
    ORDER BY username ASC"
    ) or die(mysql_error()); 
    to see the errors in your query/connection.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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