Re: Problem with PHP and PostgreSQL

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: "Seader, Cameron" <CSeader(at)idahopower(dot)com>
Cc: <pgsql-php(at)postgresql(dot)org>
Subject: Re: Problem with PHP and PostgreSQL
Date: 2004-02-04 21:18:08
Message-ID: Pine.LNX.4.33.0402041417160.29624-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

But were you pointing at the result handle or the query string when you
ran pg_num_fields?

This won't work:

$conn = pg_connect("dbname=bigdb host=myserver user=me2");
$query_panels = sprintf("SELECT... ;
$res = pg_query($conn,$query_panels);
$fieldcount = pg_num_fields($query_panels); <-- Notice I put the query
there, not the result handle...

On Wed, 4 Feb 2004, Seader, Cameron wrote:

> i did i just did not include that part of the code. sorry
>
> -----Original Message-----
> From: scott.marlowe [mailto:scott(dot)marlowe(at)ihs(dot)com]
> Sent: Wednesday, February 04, 2004 2:09 PM
> To: Seader, Cameron
> Cc: pgsql-php(at)postgresql(dot)org
> Subject: Re: [PHP] Problem with PHP and PostgreSQL
>
>
> 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...
>
>
>
>
> [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 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 received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. A2
>
>
>

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Marcel Wolf 2004-02-06 21:46:47 Creating a new database at runtime.
Previous Message Seader, Cameron 2004-02-04 21:17:03 Re: Problem with PHP and PostgreSQL