weird PHP warning
Net Llama!
netllama
Tue Jun 26 15:02:31 PDT 2007
I've got this PHP script which is pulling data from a PostgreSQL database.
In my web browser, its working fine, however when I happened to be tailing
the apache error log, I see tons of the following PHP warning:
Unable to jump to row 0 on PostgreSQL result index on line 207
Line 207 is:
$current_update2=pg_result($result2,$lt,0);
Anyone have any ideas what i'm doing wrong here?
Line 207 appears inside the following function:
function pickColorWIN_cudasmoke($gpu, $arch, $subtest, $hostemu,
$build_type, $tot_compiler) {
$db = pg_connect('host=localhost dbname=nightly
user=lfriedman');
if (!$db) {
echo ("Cannot connect to DB!");
echo pg_last_error();
exit();
}
$query0 = "SELECT current_status FROM cudasmoke where
os='WINXP32' AND gpu='$gpu' AND arch='$arch' AND subtest='$subtest' AND
hostemu='$hostemu' AND build_type='$build_type' AND
tot_compiler='$tot_compiler' ORDER BY last_update DESC LIMIT 1" ;
$query2 = "SELECT last_update FROM cudasmoke where
os='WINXP32' AND gpu='$gpu' AND arch='$arch' AND subtest='$subtest' AND
hostemu='$hostemu' AND build_type='$build_type' AND
tot_compiler='$tot_compiler' AND (SELECT now() - interval '24 hours' <
date_created::timestamp)='t' ORDER BY last_update DESC LIMIT 1" ;
$result = pg_exec($db, $query0);
$result2 = pg_exec($db, $query2);
if (!$result) {
echo "Problem with query " . $query0 . "<br/>";
echo pg_last_error();
exit();
}
if ( pg_numrows($result) == 0 ) {
print ("<td
style=\"background-color:999999\"\></td>") ;
}
else {
for ($lt=0; $lt < pg_numrows($result); $lt++) {
$current_status=pg_result($result,$lt,0);
$current_update1=pg_result($result1,$lt,0);
$current_update2=pg_result($result2,$lt,0);
if ( $current_update1 == $current_update2
) {
if ( $current_status == '<FONT
COLOR=Red><B>FAILED</B></FONT>' ) {
print ("<td
style=\"background-color:FF3300\"\></td>"); }
else {
print ("<td
style=\"background-color:66CC00\"\></td>"); } }
else {
if ( $current_status == '<FONT
COLOR=Red><B>FAILED</B></FONT>' ) {
print ("<td
style=\"background-color:990000\"\></td>"); }
else {
print ("<td
style=\"background-color:336600\"\></td>"); }
}
}
}
pg_close($db);
}
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lonni J Friedman netllama at linux-sxs.org
LlamaLand http://netllama.linux-sxs.org
More information about the Linux-users
mailing list