Jump to content


Photo

Including Two Databases in One File Conflicts


  • Please log in to reply
4 replies to this topic

#1 Xiphoid8

Xiphoid8
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 19 November 2003 - 10:38 PM

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. :)
PlanetAgeofMythology on the GameSpy Network

#2 triphis

triphis
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 20 November 2003 - 03:30 AM

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

$check1 = mysql_num_rows($result2);if($check1){you get the picture}
[/quote]
Xac Attack

#3 PHPcadet

PHPcadet
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationPlant City, Florida

Posted 20 November 2003 - 02:42 PM

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]
If builders built buildings the way programmers write programs, then the first termite to come along would destroy civilization -- Anonymous

#4 Xiphoid8

Xiphoid8
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 November 2003 - 09:17 PM

Thanks for the replies. I tried both of those methods, but I still receive the error.
PlanetAgeofMythology on the GameSpy Network

#5 Xiphoid8

Xiphoid8
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 November 2003 - 10:59 PM

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.
PlanetAgeofMythology on the GameSpy Network




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users