PDA

View Full Version : [fixed] DB error in private2.php



Swan
Thu 10th Jan '02, 5:45am
Today i got an email report complaining about a database error:

Invalid SQL:
SELECT DISTINCT user.*, session.userid AS sessionuserid FROM user
LEFT JOIN session ON (session.userid = user.userid
AND session.userid <> 0 AND user.invisible = 0 AND session.lastactivity>0)
WHERE user.userid IN() AND receivepm=1
GROUP BY user.userid ORDER BY username
mysql error: You have an error in your SQL syntax near ') AND receivepm=1
GROUP BY user.userid ORDER BY username' at line 5

mysql error number: 1064

Date: Thursday 10th of January 2002 03:33:29 AM

This is due to the IN() clause being empty. Browsing the code i found that there should be a list of buddies between the parenthesis ( .makecommas($bbuserinfo[buddylist]). ) so it looks this happens because user has no buddies... someone forgot to put a check for empty buddy lists or the problem lies elsewhere?
Thanks in advance for any answer!

p.s. btw i'm using vb 2.2.1 downloaded yesterday :)

Chen
Thu 10th Jan '02, 6:56am
Well, checkvalidbuddypm() already checks for empty buddy lists earlier, so I don't know why this would happen.
Moving to bugs tho because something must be wrong...

John
Fri 11th Jan '02, 10:23pm
Replace:

function makecommas($string) {
return str_replace(" ", ",", trim($string));
}

With:

function makecommas($string) {
if ($string=="") {
return "''";
} else {
return str_replace(" ", ",", trim($string));
}
}

John