acook Posted May 22, 2007 Share Posted May 22, 2007 Someone please help, this is driving me nuts! Here's a little background on the project: I am trying to connect to a Sybase database via PHP. I am running Fedora Core 4. I compiled PHP with unixODBC (http://www.unixodbc.org/). I installed the Sybase driver (http://www.easysoft.com/products/data_access/odbc_sybase_driver/index.html). I setup the DSN (in odbc.ini) (http://www.easysoft.com/products/data_access/odbc_sybase_driver/manual/configuration.html#815731). All seems well, except when I am pulling up the page, it tries to connnect, makes the connection, and then times out. I get the following error: Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Easysoft][sybase]Error reading from socket (0)(Success), SQL state S1T00 in SQLConnect in /var/www/html/odbc.php on line 7 connection failed: I know that I'm soooo close. It looks like it's connecting from the message Error reading from socket (0)(Success), SQL state S1T00 in SQLConnect . Here's what my php page looks like: <?php $db_user = "My username"; $db_pass = "My password"; $dsn = "SYBASE"; $conn = odbc_connect($dsn, $db_user, $db_pass); if (!$conn) {exit("connection failed: " . $conn);} odbc_close($conn); ?> Has anyone successfully gotten PHP to work with a Sybase Datatbase in Linux? Please help. Thank you for your time. Quote Link to comment Share on other sites More sharing options...
acook Posted May 23, 2007 Author Share Posted May 23, 2007 Nobody has connected to an ODBC Datasource via PHP in Unix? Quote Link to comment Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 from the error... theres a few possibilities from whats going wrong here 1) incorrect username/password/database 2) oracle isnt set up correctly/completly/properly ... thats all of the reasons i can think of currently... Quote Link to comment Share on other sites More sharing options...
acook Posted May 23, 2007 Author Share Posted May 23, 2007 Ok, would anyone have a sample script I could use to actually test the connection and display the results in the log and/or on the screen? Thank you. Quote Link to comment Share on other sites More sharing options...
AV1611 Posted May 23, 2007 Share Posted May 23, 2007 I use ODBC under linux in PHP all the time... but I've never used sybase Are you sure your ODBC is set up correctly? Have you looked up the error code ODBC is giving you? Here is a sample from a Visual Basic ODBC Source query in PHP if it helps: $connect = odbc_connect("DSN", "", ""); $query = "SELECT..."; $result = odbc_do($connect, $query); WHILE($row=odbc_fetch_array($result)) { ... } odbc_close($connect); Quote Link to comment Share on other sites More sharing options...
acook Posted May 23, 2007 Author Share Posted May 23, 2007 I tried some of the above script and am still getting the same error as well as others: Warning: odbc_do(): supplied argument is not a valid ODBC-Link resource in /var/www/html/odbc.php on line 9 Warning: odbc_fetch_array(): supplied argument is not a valid ODBC result resource in /var/www/html/odbc.php on line 10 Warning: odbc_close(): supplied argument is not a valid ODBC-Link resource in /var/www/html/odbc.php on line 14 Hmmm, perhaps I am doing something else wrong. Here's my situation: My company uses AR Systems Remedy for their ticketing system. As it is right now, I have an Excel spreadsheet with a macro that connects to the datasource and generates results. This spreadsheet works perfectly. It uses an AR System ODBC Driver to connect to the database (in Windows). I am told that this is a Sybase database but I am unable to confirm. What I ultimately want to do is take the Excel macro and convert it to a PHP page. I am pretty familiar with PHP, but am new to ODBC (espically in Linux). So, I installed PHP with unixODBC (actually YUM did it for me). I then downloaded the Sybase driver. It seems as though it is trying to connect...it tries to load the page for about 30 seconds and then I get that message: "Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Easysoft][sybase]Error reading from socket (0)(Success), SQL state S1T00 in SQLConnect in /var/www/html/odbc.php on line 7 " My line 7 is the actual connection line: $connect = odbc_connect("$dsn", "$db_user", "$db_pass"); If I edit my /etc/odbc.ini file and change it to the wrong port number and refresh the page I automatically get an error telling me that it couldn't connect: Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Easysoft][sybase]Failed in call connect(111/Connection refused) at myservername on port 21000., SQL state 08001 in SQLConnect in /var/www/html/odbc.php on line 7 Here is my /etc/odbc.ini file: [sYBASE] Driver = SYBASE User = Firstname Lastname Password = mypass SERVER_HOST = myserver.net SERVER_PORT = 22000 And here is my /etc/odbcinst.ini file: [sYBASE] Description = Easysoft ODBC Sybase Driver Driver = /usr/local/easysoft/sybase/libessybase.so Setup = /usr/local/easysoft/sybase/libessybasesetup.so FileUsage = 1 UsageCount = 1 Does everything look ok? Thanks again guys. I really appriciate the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.