PHPNuke SQL Error (installing messenger)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sL|De
Forum Newbie
Posts: 1
Joined: Thu Apr 10, 2003 5:01 pm

PHPNuke SQL Error (installing messenger)

Post by sL|De »

just another php n00b lookin for answers...

im trying to install a instant messenger system for phpnuke. Comes with 2 php files.

BlockMessenger.php in the root phpnuke directory.

and block-messenger.php in ../blocks

here is the error its giving me


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in BlockMessenger.php on line 196

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in BlockMessenger.php on line 198


here are lines 196 and 198

$member_online_num = mysql_num_rows($sql);

while ($session = mysql_fetch_array($sql)) {

and here is where $sql is defined

$sql = mysql_query("SELECT username FROM $prefix"._session." where guest=0");

any ideas?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Code: Select all

.$session.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Should it maybe be:

Code: Select all

$sql = mysql_query("SELECT username FROM ".$prefix."_session WHERE guest=0");
One thing that can make it a lot easier to debug SQL statements is to change the code from:

Code: Select all

$sql = "SELECT username FROM $prefix"._session." WHERE guest=0";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>'); 
$member_online_num = mysql_num_rows($result); 

while ($session = mysql_fetch_array($result)) {
as using mysql_error() and an or die() statement should give you a more useful (MySQL generated) error message.

Mac
Post Reply