Re: Problem with PHP and PostgreSQL - Mailing list pgsql-php

From scott.marlowe
Subject Re: Problem with PHP and PostgreSQL
Date
Msg-id Pine.LNX.4.33.0402041407530.29327-100000@css120.ihs.com
Whole thread Raw
In response to Problem with PHP and PostgreSQL  ("Seader, Cameron" <CSeader@idahopower.com>)
List pgsql-php
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.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

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...


pgsql-php by date:

Previous
From: "Seader, Cameron"
Date:
Subject: Problem with PHP and PostgreSQL
Next
From: "Seader, Cameron"
Date:
Subject: Re: Problem with PHP and PostgreSQL