pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chadwick Rolfs <cmr@shell.gis.net>
To: Bruce Young <hbrucey@yahoo.com>
Cc: pgsql-php@postgresql.org
Subject: Re: can't retrieve data through PHP
Date: Sat, 26 Oct 2002 14:49:53 -0400 (EDT)
Message-ID: <Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net> (raw)
In-Reply-To: <20021026183940.32531.qmail@web10404.mail.yahoo.com>

A better way to to db connection (without extra modules or anything),
would be to make a small .php file with your connect command in it.  Then
you include that file in each of your scripts that need it (probably at
the top, or whereever).  This may eliminate the need to make a new
connection, since your actual connect script never changes.  It also
drastically reduces errors, and if put into a non-web findable directory
(but it has to be readable by the web-server/php), it can be far more
secure.

Take care.  If anything above is misinformation, please correct me :>

On Sat, 26 Oct 2002, Bruce Young wrote:

> thanks guys for the quick response and tips.
> everything works well now. dont know how i didnt catch that one.. :)
> 
>   - bruce 
> 
> --- Chadwick Rolfs <cmr@shell.gis.net> wrote:
> > Your variables don't match.  And your coding is very inconsistent. 
> > The if
> > construct should follow the for construct.  It makes everything
> > READABLE
> > and understandable.
> > Good luck
> > 
> > On Sat, 26 Oct 2002, Bruce Young wrote:
> > 
> > > php connection query:
> > > 
> > > <?php
> > >         #include('DB/pgsql.php');
> > > 
> > > 	$dbconnect = pg_connect("dbname=campus user=apache");
> > 
> > HERE YOU HAVE DBCONNECT	
> > 
> > > 	
> > > 	
> > > 	$result = pg_exec ($conn, "select * from friends");	
> > 
> > HERE YOU HAVE CONN
> > 
> > > 	if (!result) {printf ("Error\n"); exit;}
> > > 
> > > 	$numrows = pg_num_rows($result);
> > > 	
> > > 	for ($i=0; $i < $numrows; $i++) {
> > > 	   $r = pg_fetch_row($result, $i);
> > > 
> > > 	   for ($j=0; $j < count($r); $j++) {
> > > 	      echo "$r[$j] ";
> > > 	   }
> > > 	   echo "<br>";
> > >        }
> > > 	pg_close($dbconnect);
> > > ?>
> > > 
> > > 
> > > --- dan radom <dan@radom.org> wrote:
> > > > * Bruce Young (hbrucey@yahoo.com) wrote:
> > > > > my script that does insert works correctly, but i get this
> > error
> > > > when
> > > > > retrieving data:
> > > > > 
> > > > > Warning: pg_exec(): supplied argument is not a valid
> > PostgreSQL
> > > > link
> > > > > resource in /home/httpd/htdocs/view.php on line 115
> > > > > 
> > > > > Warning: pg_num_rows(): supplied argument is not a valid
> > > > PostgreSQL
> > > > > result resource in /home/httpd/htdocs/view.php on line 118
> > > > > 
> > > > 
> > > > how about showing us the connection and query parts of view.php
> > > > 
> > > > dan
> > > > 

-Chadwick




view thread (6+ messages)

Message-ID: <Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net>
Permalink:  ../Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net/
Also on:    postgresql.org/message-id/Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: cmr@shell.gis.net, hbrucey@yahoo.com
  Subject: Re: can't retrieve data through PHP
  In-Reply-To: <Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net>
  References: <20021026183940.32531.qmail@web10404.mail.yahoo.com> <Pine.SOL.3.96.1021026144328.19582E-100000@shell.gis.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox