Jump to content

Archived

This topic is now archived and is closed to further replies.

Xiphoid8

Including Two Databases in One File Conflicts

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. :)

Share this post


Link to post
Share on other sites

Hmm, have you tried having the mysql_num_rows outside the \"if\" statement?

 

$check1 = mysql_num_rows($result2);

if($check1){



you get the picture



}

Share this post


Link to post
Share on other sites

I thought mysql_num_rows returns a number. Shouldn\'t the if statement be like this?:

[php:1:ef30ccf0ab]<?php

$check1 = mysql_num_rows($result2);

if($check1 == 0){

}

?>[/php:1:ef30ccf0ab]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.