LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-12-2005, 07:11 PM   #1
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
Postgresql and PHP4 not working on Debian


Hi

I have used mysql in the past, and I though I might have a look at postgresql (7.4.8). Well, I installed that and I can conenct through the command line, it shows up on a portscan (port 5432) so it appears to be working. I created a new user (tom) and went to look at getting it to work with php4 on apache2.

I installed php4-pgsql, and made a simple test file. It didn't work (I can't remember the error). So I tried to connect using pear:B and I got this message:

DB Error: connect failed

This is the php script:

PHP Code:
<?php
require_once('DB.php');
  
$dsn = array(
        
'phptype'  => 'pgsql',
        
'hostspec' => 'localhost',
        
'database' => 'tom',
        
'username' => 'tom',
        
'password' => ''
  
);
  
$db DB::connect($dsn);

  if (
DB::isError($db)) {
    die (
$db->getMessage());
  }

?>
Is there something I'm doing wrong here? I know the database 'tom' exists, I know the use 'tom' exists, and I modified the 'phptype' to mysql and it worked.

Thanks in advance,

Tom.
 
Old 10-12-2005, 07:52 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
How is Postgres set-up?
hint: pg_hba.conf


Cheers,
Tink
 
Old 10-12-2005, 08:07 PM   #3
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Original Poster
Rep: Reputation: 30
This is at the end of the file (the top 50 or so lines are comments):

Code:
# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHOD
# Database administrative login by UNIX sockets
local   all         postgres                                        ident sameuser
#
# All other connections by UNIX sockets
local   all         all                                             ident sameuser
#
# All IPv4 connections from localhost
host    all         all         127.0.0.1         255.255.255.255   ident sameuser
#
# All IPv6 localhost connections
host    all         all         ::1               ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff        ident sameuser
host    all         all         ::ffff:127.0.0.1/128                ident sameuser
#
# reject all other connection attempts
host    all         all         0.0.0.0           0.0.0.0           reject
(I haven't messed with any of postgresql config files yet)
 
Old 10-12-2005, 08:17 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Assuming that OS username equals DB username this line
Code:
local   all         all                                             ident sameuser
should catch you. Next question would be whether you
can connect to the database outside of PHP. Open a
console (as user tom) and go
psql

If that fails, check postgres' logfile.




Cheers,
Tink

Last edited by Tinkster; 10-12-2005 at 08:18 PM.
 
Old 10-12-2005, 08:43 PM   #5
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Original Poster
Rep: Reputation: 30
I can connect fine from the command line using the user tom so I don't think it's a problem with postgresql, rather with php4. Would you like me to post phpinfo() here or some other place?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help loading php4-gd with php4 already installed. (Debian) sdduuuude Linux - Software 3 10-24-2005 05:13 AM
Apache2 and php4 in Debian swmok Debian 1 06-09-2005 05:21 PM
php4 with apache2? the debian way, how? Tisch Debian 4 08-19-2004 09:35 AM
Apache + PHP4 on Debian Mikessu Linux - Networking 3 12-31-2003 12:59 AM
Totally lost - RH 7.1, apache, php4, postgreSQL setup marktaff Linux - Newbie 1 09-19-2001 03:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration