...

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



bruceleejr
06-19-2010, 12:50 AM
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.


$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:



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

bruceleejr
06-19-2010, 12:53 AM
Here is the whole 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);
?>

abduraooft
06-19-2010, 09:50 AM
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

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum