Jump to content

Including Two Databases in One File Conflicts


Xiphoid8

Recommended Posts

I\'m trying to include two databases (one that contains member info and another that holds file info) in my index.php to show the last five members to register and the most recently uploaded files.

 

I have each of my database connection strings in separate files and I\'ve included them in the file I\'m working on.

 

I\'m receiving the following error:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 

I thought at first it was because I had the same variable names in my database connection files, so I changed those and I\'m still this error.

 

Here\'s more of my code if that helps:

 

$result = mysql_query("SELECT * FROM users ORDER BY user_date_registered DESC LIMIT 0, 5");



if (mysql_num_rows($result)) 

{



print "<table>";



print "<tr><td colspan=2><h4>Newest Members</h4></td></tr>";



while ($qry = mysql_fetch_array($result)) 

{

 	print "<tr><td>$qry[user_id]</td><td>$qry[user_name]</td>";

 	print "</tr>";

}



print "</table>";



}







$result2 = mysql_query("SELECT * FROM games ORDER BY game_date_uploaded DESC LIMIT 0, 5");



if (mysql_num_rows($result2)) 

{



print "<BR><BR><CENTER><table border=1 cellspacing=0 bordercolor=#000000 bgcolor=#323741>n</CENTER>";



print "<tr><td colspan=2><h4>Newest Games</h4></td></tr>";



while ($qry2 = mysql_fetch_array($result2)) 

{

 print "<tr><td>$qry2[game_id]</td><td>$qry2[game_name]</td>";

 print "</tr>";

}



print "</table>";



}

 

Thanks in advance for any help. Hopefully there is a way to do this. :)

Link to comment
Share on other sites

For reference for anyone who searches this thread... here\'s how I fixed it:

 

$result2 = mysql_query("SELECT * FROM files.games ORDER BY game_date_uploaded DESC LIMIT 0, 5");

 

All I had to do was specify the database and table, where as before I was just naming the table.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.