[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PHP + PostgreSQL



Oliver Elphick wrote:
I'm not a PHP user; however I have looked at its manual and I presume
that pg_connect calls PQconnectdb in libpq.  The comma is certainly
wrong; parameters should be separated by whitespace.  Parameters with no
value should be omitted altogether or else defined as '' (a pair of
single quotes).  Any parameter containing a space must be enclosed in
single quotes.

I suggest this:

<?php
function opendb() {
    global $host, $username, $database, $password;
    $conninfo = "";
    if ($host != "")
        $conninfo = "host=" . $host;
    $conninfo .= " dbname=" . $database;
    $conninfo .= " user=" . $username;
    if ($password != "")
        $conninfo .= " password='" . $password . "'";
    $dbconn = pg_connect($conninfo) or die("Cannot connect");
    return $dbconn;
}

I'm using concatenation rather than inclusion of variables, because
inclusion doesn't seem to work, judging by your error messages.  I also
assume that $database and $username are never going to be empty.

Oliver Elphick
  

thanks oliver.....
but i still get the same error. i think it's postgresql auth. problem ( ...or i dunno)
in the latest howto ( as i sent within my e-mail before ) there's differences in how to treath
postgresql 7.2 and 7.3 which acoording to the howto those are the only postgre environtment this
techtables has been tested.
since i'm running sid with postgresql 7.4.3, i guess there will be another setting need to be applied.
( example : it said i need to change the value "ident sameuser" to "MD5" in pg_hba.conf so postgre
 will ask for password: in my experience it's failed and when i try to replace "MD5" with "password"
.......there ... i made it )
and...since i'm an novice in everything, i guess this is the right time to start learning some database
thing. ( and so php scripting.... :-( ).
and if there's somebody in this room who has similiar system environtment with me ( deb sid 2.4.26
postgres 7.4.3 php 4.3.4 apche 1.3.31 ) would like to try this techtables and share your experince
with me...that would be very nice.

cheers,

 --me--

techtables home site -->  http://sourceforge.net/projects/techtables


Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: