View Full Version : argh!
anyone see why this query shouldn't return any results? if not, could someone please explain exactly what conditions they see in the SELECT statement, so i can go through and double-check everything? thanks.
btw, it's part of an addon i'm making that i *may* release, so i'll be sure to give credit.
...
$start=$pagenumber*$linksperpage;
$end=$start+$linksperpage;
$links=$DB_site->query("SELECT user.username,link.* FROM link LEFT JOIN user ON (user.userid=link.userid) WHERE link.folderid='".$folderid."' LIMIT $start, $end");
while ($link=$DB_site->fetch_array($links)) {
$link[date]=vbdate("m-d-Y",$link[dateline]);
$link[time]=vbdate("h:i A",$link[dateline]);
$link[rating]=round($link[points]/$links[voters],1);
eval("\$linkbits .= \"".gettemplate("links_listbit")."\";");
}
...
Xenon
02-16-2003, 09:55 AM
hmm, it wouldn't return any results if $folderid isn't set up right or if $pagenumber=0 and $linksperpage=0 from what i can see..
here's the part just above that. note that $linksperpage is a setting i added in the admin cp.
...
if ($pagenumber=="") {
$pagenumber="1";
}
$start=$pagenumber*$linksperpage;
$end=$start+$linksperpage;
...
thanks for the reply
Xenon
02-16-2003, 04:45 PM
hmm use that if clause instead it's better because it will catch more buggy pagenumbers..
if (intval($pagenumber)==0) {
$pagenumber=1;
}
good point, but that doesn't seem to be what's causing it. still changed it though.
Xenon
02-16-2003, 08:45 PM
hmm is it called within a function?
maybe you've forgotten to globalize $linksperpage..
nope, it's not in a function. :( any other ideas?
Xenon
02-17-2003, 05:02 PM
hmm, normally this should return a division by zero i think...
this line:$link[rating]=round($link[points]/$links[voters],1);
should be this, am i right?:$link[rating]=round($link[points]/$link[voters],1);
what's different about the second one?
oh, got it. thanks. the listing still shows nothing though.
i also tried simplifying the query to see if that was the problem. i changed it to:
$links=$DB_site->query("SELECT * FROM link WHERE folderid='".$folderid."' LIMIT $start, $end");
still no luck.
Xenon
02-17-2003, 08:13 PM
but you are sure it's already filled correctly? ^^
try these two:$links=$DB_site->query("SELECT * FROM link WHERE folderid=".intval($folderid)." LIMIT $start, $end");
and if that doesnt help just test it with this
$links=$DB_site->query("SELECT * FROM link");
you just barely beat me. i solved the problem:
$pagenumber=$pagenumber-1;
$start=($pagenumber*$linksperpage);
$end=$start+$linksperpage;
$links=$DB_site->query("SELECT user.username,link.* FROM link LEFT JOIN user ON (user.userid=link.userid) WHERE link.folderid='".$folderid."' LIMIT ".$start.", ".$end);
while ($link=$DB_site->fetch_array($links)) {
$link[date]=vbdate("m-d-Y",$link[dateline]);
$link[time]=vbdate("h:i A",$link[dateline]);
$link[rating]=round($link[points]/$link[voters],1);
eval("\$linkbits .= \"".gettemplate("links_listbit")."\";");
}
if you didn't notice, i screwed up my limiting variables. i needed to subtract 1 from the pagenumber, so that page 1 would start from record 0, page 2 from 20, page 3 from 40, etc.
thanks for your help, i wouldn't have noticed some things.
Xenon
02-17-2003, 08:31 PM
glad it works now :)
you're welcome :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.