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 27432D1D179 for ; Wed, 4 Feb 2004 21:15:16 +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 59647-01 for ; Wed, 4 Feb 2004 17:15:14 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 0B114D1C512 for ; Wed, 4 Feb 2004 17:15:12 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i14LDD3F002186; Wed, 4 Feb 2004 14:13:13 -0700 (MST) Date: Wed, 4 Feb 2004 14:09:08 -0700 (MST) From: "scott.marlowe" To: "Seader, Cameron" Cc: Subject: Re: Problem with PHP and PostgreSQL In-Reply-To: <71B8A8BEC516CF46835CA629156CF211103829@bedford.idacorp.local> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/19 X-Sequence-Number: 2567 On Wed, 4 Feb 2004, Seader, Cameron wrote: > 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.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 = 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 You need to connect to the database and execute your query: $conn = pg_connect("dbname=bigdb host=myserver user=me2"); $query_panels = sprintf("SELECT... ; $res = pg_query($conn,$query_panels); $fieldcount = pg_num_fields($res); etc...