odbc problem using PHP

Issues related to configuring your network
Post Reply
hkrenske
Posts: 5
Joined: 2017/04/22 08:43:58

odbc problem using PHP

Post by hkrenske » 2018/02/18 06:39:35

I am running postgresql on Centos 7 as well as hosting a website which uses data from the postgresql database. I am using PHP. Everytime I try to access any data from a browser screen it returns the following error:

Warning: odbc_connect(): SQL error: [unixODBC]Could not connect to the server; Could not connect to remote socket immedaitely, SQL state 08001 in SQLConnect in /var/www/html/_210db/dbms_fns.php on line 5

I would really appreciate some advice on how to correct the problem that I have encountered. If you need any other configuration files I will send them.

The web site used to work using centos 5.

Thanks for any help you can give me.
Hugh Krenske

ODBC files are
/etc/odbcinst.ini
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/psqlodbc.so
Setup = /usr/lib/libodbcpsqlS.so
Driver64 = /usr/lib64/psqlodbcw.so
#Driver64 = /usr/lib64/libodbcpsqlS.so.2.0.0
Setup64 = /usr/lib64/libodbcpsqlS.so
FileUsage = 1

/etc/odbc.ini
[rbcn]
Description = Environment database
Driver = PostgreSQL
Trace = 1
TraceFile = /var/log/sql.log
Database = rbcn
Servername = gudgeon2
Username = tell
Password = tell.01
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =

Runnning some tests have produced the following results:
# isql -v rbcn
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>

# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

Programs installed on my Centos 7 server are:

# yum list installed | grep ODBC
unixODBC.x86_64 2.3.1-11.el7 @base

# yum list installed | grep odbc
libiodbc.x86_64 3.52.7-7.el7 @anaconda
php-odbc.x86_64 5.4.16-43.el7_4 @updates
postgresql-odbc.x86_64 09.03.0100-2.el7 @base

# yum list installed | grep postgres
postgresql.x86_64 9.2.23-3.el7_4 @updates
postgresql-docs.x86_64 9.2.23-3.el7_4 @updates
postgresql-libs.x86_64 9.2.23-3.el7_4 @updates
postgresql-odbc.x86_64 09.03.0100-2.el7 @base
postgresql-server.x86_64 9.2.23-3.el7_4 @updates

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: odbc problem using PHP

Post by TrevorH » 2018/02/18 11:48:21

Try setsebool -P httpd_can_network_connect_db 1
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hkrenske
Posts: 5
Joined: 2017/04/22 08:43:58

Re: odbc problem using PHP

Post by hkrenske » 2018/02/18 20:34:50

Thank you so much. I have struggled with this for days. Now in my 70s, I support local environment groups with a way that they can collectively record the work they have done and easily search on historic data. I presume that by leaving out the -P in the line will make the change permanent across reboots.
Again many thanks.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: odbc problem using PHP

Post by TrevorH » 2018/02/18 20:41:20

The opposite, the -P makes it permanent, without it it only lasts for one boot.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hkrenske
Posts: 5
Joined: 2017/04/22 08:43:58

Re: odbc problem using PHP

Post by hkrenske » 2018/02/19 01:13:09

Thanks

Post Reply