Thread: PHP/PostGreSQL Articles

PHP/PostGreSQL Articles

From
David Costa
Date:
Hello ;)

I manage a small albeit promising website (not for profit, no ads, no
subscriptions) dedicated to PHP Programming (http://www.dotgeek.org)

We (I) are looking for writers on the following topics:

-Articles  with examples of PHP and postgresql development
- Migration from Mysql to Postgresql

I might be willing to pay for good articles, (payment per article or on
a deal basis).

The budget is modest but it could fit well if you are a student and
have some spare time handy.

It could be something fun and interesting at the same time.

Feel free to msg email me at geeks at dotgeek dot org  for any further
information,

Regards
David Costa


Can't connect to 7.4 DB

From
Michael Hanna
Date:
Hi this php code:



    // add to DB

    // database access parameters
    $host = "localhost";
    $user = "postgres";
    $pass = "postgres";
    $db = "cosc3p94";

    // open a connection to the database server
    $connection = pg_connect("host=$host dbname=$db user=$user
password=$pass");

    if (!$connection)
    {
            die("Could not open connection to database server");
    }


    ...

results in:

Could not open connection to database server

and I'm not sure why. The web browser, web server, and database are on
the same machine..

I checked the pg_hba.conf and it says this:

# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK
METHOD

local   all         all
trust
# IPv4-style local connections:
host    all         all         127.0.0.1         255.255.255.255
trust
# IPv6-style local connections:
host    all         all         ::1
ffff:ffff:ffff:ffff:ffff:ffff:ff$


which is untouched from the default settings...

Michael


Re: Can't connect to 7.4 DB

From
"scott.marlowe"
Date:
OK, here's a little trick you may not be aware of.

pg_connect("dbname=mydb user=stan");

will open a local unix domain socket.

pg_connect("host=127.0.0.1 dbname=mydb user=stan");

will open a local TCP/IP connection on the loopback interface.

In order for this to work, your postgresql.conf must have this line
changed:
#tcpip_socket = false
to
tcpip_socket = true

and your pg_hba.conf needs a line like this:

host    all         all         127.0.0.1         255.0.0.0   trust

So it's likely the "secure by default" mentality of postgresql that's
biting you here.


Re: Can't connect to 7.4 DB

From
Joshua Drake
Date:
Hello,

What does the PostgreSQL log say? Is it even getting to the server? What
abour the apache error log? Does it reflect an error?

Sincerely,

Joshua D. Drake


Michael Hanna wrote:
> Hi this php code:
>
>
>
>     // add to DB
>
>     // database access parameters
>     $host = "localhost";
>     $user = "postgres";
>     $pass = "postgres";
>     $db = "cosc3p94";
>
>     // open a connection to the database server
>     $connection = pg_connect("host=$host dbname=$db user=$user
> password=$pass");
>
>     if (!$connection)
>     {
>             die("Could not open connection to database server");
>     }
>
>
>     ...
>
> results in:
>
> Could not open connection to database server
>
> and I'm not sure why. The web browser, web server, and database are on
> the same machine..
>
> I checked the pg_hba.conf and it says this:
>
> # TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHOD
>
> local   all         all                                             trust
> # IPv4-style local connections:
> host    all         all         127.0.0.1         255.255.255.255   trust
> # IPv6-style local connections:
> host    all         all         ::1
> ffff:ffff:ffff:ffff:ffff:ffff:ff$
>
>
> which is untouched from the default settings...
>
> Michael
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend


Attachment

Re: Can't connect to 7.4 DB

From
Michael Hanna
Date:
yes, this was the problem, thanks...

On 12-Feb-04, at 10:30 AM, scott.marlowe wrote:
>
> In order for this to work, your postgresql.conf must have this line
> changed:
> #tcpip_socket = false
> to
> tcpip_socket = true


Re: PHP/PostGreSQL Articles

From
"Nick Fankhauser"
Date:
Hi David-

Although you'll find the PHP experts on this list, you may have more luck
finding authors on the advocacy list. I'll cc the advocacy list on this
response. I'm pretty sure that migration from MySQL to PostgreSQL will be a
popular topic in that group.

Regards,
     -Nick



> -----Original Message-----
> From: pgsql-php-owner@postgresql.org
> [mailto:pgsql-php-owner@postgresql.org]On Behalf Of David Costa
> Sent: Wednesday, February 11, 2004 5:22 PM
> To: pgsql-php@postgresql.org
> Subject: [PHP] PHP/PostGreSQL Articles
>
>
> Hello ;)
>
> I manage a small albeit promising website (not for profit, no ads, no
> subscriptions) dedicated to PHP Programming (http://www.dotgeek.org)
>
> We (I) are looking for writers on the following topics:
>
> -Articles  with examples of PHP and postgresql development
> - Migration from Mysql to Postgresql
>
> I might be willing to pay for good articles, (payment per article or on
> a deal basis).
>
> The budget is modest but it could fit well if you are a student and
> have some spare time handy.
>
> It could be something fun and interesting at the same time.
>
> Feel free to msg email me at geeks at dotgeek dot org  for any further
> information,
>
> Regards
> David Costa
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>
>