X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D5BAD1D8C1 for ; Wed, 4 Feb 2004 20:20:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33852-09 for ; Wed, 4 Feb 2004 16:20:15 -0400 (AST) Received: from Ariel2.idahopower.com (unknown [204.76.195.72]) by svr1.postgresql.org (Postfix) with SMTP id 49DCDD1D287 for ; Wed, 4 Feb 2004 16:20:08 -0400 (AST) Received: from 204.76.195.33 by Ariel2.idahopower.com with ESMTP (IPCo Mail Relay at your service (MMS v4.7);); Wed, 04 Feb 2004 13:14:38 -0700 X-Server-Uuid: c4da1ae6-7048-11d2-bc8e-00a083360239 Received: from bedford.idacorp.local ([172.18.201.66]) by midway.idacorp.local with Microsoft SMTPSVC(5.0.2195.6713); Wed, 4 Feb 2004 13:20:04 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Subject: Problem with PHP and PostgreSQL Date: Wed, 4 Feb 2004 13:20:04 -0700 Message-ID: <71B8A8BEC516CF46835CA629156CF211103829@bedford.idacorp.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Problem with PHP and PostgreSQL Thread-Index: AcPrXEZlreivpJOcRJS/3LdxNgQHRg== From: "Seader, Cameron" To: pgsql-php@postgresql.org X-OriginalArrivalTime: 04 Feb 2004 20:20:04.0867 (UTC) FILETIME=[467DBD30:01C3EB5C] X-WSS-ID: 6C3F8D24489249-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/18 X-Sequence-Number: 2566 I am having trouble with the following loops and such and accessing Postgre= SQL database. The errors i get are: Warning: pg_num_fields(): supplied argument is not a valid PostgreSQL resul= t resource in /var/www/html/PMS/csv_export.php on line 108 Warning: pg_fetch_row(): supplied argument is not a valid PostgreSQL result= resource in /var/www/html/PMS/csv_export.php on line 118 Here is my Code Below: //**** SQL Query $query_panels =3D 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=20 $fieldcounts =3D pg_num_fields($query_panels);=20 //**** List fields as first Row=20 for($i =3D 0; $i < $fieldcounts; $i++) {=20 $fieldtype =3D pg_fieldtype($query_panels, $i);=20 echo "$fieldtype->name";=20 if ($i < ($fieldcounts-1))=20 echo ","; else echo "\n";=20 }=20 //**** Output each row of Data=20 while ($myrow =3D pg_fetch_row($query_panels))=20 {=20 for($i =3D 0; $i < $fieldcounts; $i++)=20 {=20 $fieldname =3D pg_fieldname($query_panels, $i);=20 if ($i < ($fieldcounts-1)) echo $myrow[$fieldname] . ", ";=20 else echo $myrow[$fieldname] . "\n";=20 }=20 } 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 applicable law. If you are not the int= ended recipient, you are hereby notified that any disclosure, copying, dist= ribution, or use of the information contained herein (including any relianc= e thereon) is STRICTLY PROHIBITED. If you received this transmission in err= or, please immediately contact the sender and destroy the material in its e= ntirety, whether in electronic or hard copy format. Thank you. A2