0

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=tcpip(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

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
amrobinson
  • 1
  • 1
  • 2
  • Do you have the driver for the DB type? – Phill Pafford Oct 29 '09 at 17:38
  • Set up odbc connection to sybase (successfully) in odbc administrator, then using php odbc connect to take advantage of that. – amrobinson Oct 29 '09 at 17:55
  • I appreciate your looking at this, I'd be happy to discuss it in detail, I am really on the hook for this. Thanks. – amrobinson Nov 02 '09 at 02:10
  • I updated the item with some code, as requested. – amrobinson Nov 02 '09 at 02:11
  • The error IM002 points to ServerName (winpest) being an incorrect system data source name, while you were expecting it, I guess, to be the name declared in/by the ASA server. Can you try using the alternative form of the ASA connection parameters: ENG instead of ServerName? – pascal Nov 04 '09 at 23:37
  • Did you explicitly change the "database name" in the ASA service definition (assuming dbsrv7 is actually running as a service)? For a database file windata.db, the default database name would be "windata" not "windata.db" as used in $db_name. – pascal Nov 04 '09 at 23:39

1 Answers1

0

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.

pascal
  • 3,287
  • 1
  • 17
  • 35
  • Actually using the multi-user program, dbsrv7.exe instead of dbeng7.exe. Do you mean that the program 'dbserv7.exe' should be on the path, not just the directory it's in? Also, for a permission problem, I've updated the folder in which the database file is, or should I be doing something with User Accounts? – amrobinson Nov 04 '09 at 22:22
  • No, as usual, it's just the name of the directory of dbsrv7.exe which needs to be in PATH, not "dbsrv7.exe" itself. – pascal Nov 04 '09 at 23:25
  • I double-checked the pathway, tried setting ENG variable, looked at the permissions on the web file folder...still not working. – amrobinson Nov 05 '09 at 04:32