I want to use PDO to connect to a Sybase using PHP pdo_dblib
. This is what I have done:
$conn = new PDO("dblib:host=$db_host:$db_port;dbname=$db_name","$login","$password");
It shows me SQL Null error
. I don't know how to get it right. I have checked the php info, and the pdo_dblib is there.
PDO Driver for FreeTDS/Sybase DB-lib: Flavour
enabled: freetds
by the way, is the database port needed? Before this, I didn't put the database port number, plus now I'm still unable to get the port number.
Follow these steps to find the cause of the error
Step1: Connecting using telnet.
xxx@ubuntuvbox:~$ telnet 10.1.1.1 5000
Trying 10.1.1.1...
Connected to 10.1.1.1.
Step2: Configure FreeTDS
Edit freetds.conf, located in /etc/freetds/ (Ubuntu 11.10)
[global]
# TDS protocol version
tds version = 5.0
text size = 64512
Step3: Connecting using FreeTDS
xxx@ubuntuvbox:~$ sqsh -S 10.1.1.1:5000 -Usa
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
Password:
Msg 2401, Level 11, State 2
Server 'XXXXXX'
Character set conversion is not available between client character set 'utf8'
and server character set 'cp850'.
No conversions will be done.
1> select * from .....
Step4: Connecting using FreeTDS with PHP
Check this...
$dbh = new PDO ('dblib:host=10.1.1.1:5000;dbname=databasename','sa','password');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.