PHP ODBC connect not connecting to Sybase db
I set up a web site using PHP to talk to a Sybase db (already in use for a in-house application) via an ODBC connection, so users in the field could access the in-house db. This was on a 2003 NT server, and everything worked fine.
Then I set up a similar site on an XP Pro machine (this time, by myself), and while the web site is accessible, and the PHP programming works, the PHP pages cannot access the db. I get no errors, I've checked phpinfo
between the two sites (working and non-working) and have come up with no ideas.
Convinced the connect to database via ODBC not working, should the configuration on an XP Pro be different than from a 2003 NT machine? ODBC is set up the same way on both machines.
<?php
$Page_Name = "apptlist1.php";
import_request_variables('gpc');
$db_host = "wintermlocal";
$db_server_name = "winpest";
$db_name = "windata.db";
$db_file = "c:\data\windata.db";
$db_conn_name = "php_script";
$db_user = "dba";
$db_pass = "sql";
//================================================================
$connect_string = "Driver={Adaptive Server Anywhere 7.0};"
."CommLinks=tcp开发者_Go百科ip(Host=$db_host);"
."ServerName=$db_server_name;"
."DatabaseName=$db_name;"
."DatabaseFile=$db_file;"
."ConnectionName=$db_conn_name;"
."uid=$db_user;pwd=$db_pass";
//================================================================
$connect = odbc_connect($connect_string,'','');
?>
Warning: odbc_connect() [function.odbc-connect]:
SQL error: [Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified
SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\allpro\apptlist1.php on line 22
You're saying that $doresult is 0, but in fact the problem is that $connect is 0, correct?
It could be the protections on the .db file.
Is the database already run by some ASA service engine (which would define server=winpest, dbname=windata) or do you expect the PHP script to start the engine if needed? In that case, I often had problems around the database engine (dbeng7) not being in the system path, which prevents the ODBC driver from starting the engine database on request.
精彩评论