I am having trouble with the following loops and such and accessing PostgreSQL database.
The errors i get are:
Warning: pg_num_fields(): supplied argument is not a valid PostgreSQL result resource in
/var/www/html/PMS/csv_export.phpon line 108
Warning: pg_fetch_row(): supplied argument is not a valid PostgreSQL result resource in
/var/www/html/PMS/csv_export.phpon line 118
Here is my Code Below:
//**** SQL Query
$query_panels = sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST' BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM_param4__panels);
//**** Count Fields
$fieldcounts = pg_num_fields($query_panels);
//**** List fields as first Row
for($i = 0; $i < $fieldcounts; $i++)
{
$fieldtype = pg_fieldtype($query_panels, $i);
echo "$fieldtype->name";
if ($i < ($fieldcounts-1))
echo ","; else echo "\n";
}
//**** Output each row of Data
while ($myrow = pg_fetch_row($query_panels))
{
for($i = 0; $i < $fieldcounts; $i++)
{
$fieldname = pg_fieldname($query_panels, $i);
if ($i < ($fieldcounts-1)) echo $myrow[$fieldname] . ", ";
else echo $myrow[$fieldname] . "\n";
}
}
Why do i get those errors?
Why is it not a valid result resource?
any help would be awsome.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential and/or exempt from disclosure under
applicablelaw. If you are not the intended recipient, you are hereby notified that any disclosure, copying,
distribution,or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
receivedthis transmission in error, please immediately contact the sender and destroy the material in its entirety,
whetherin electronic or hard copy format. Thank you. A2