Page 1 of 1

[SOLVED] Sybase killing me once again

Posted: Mon Dec 03, 2007 6:29 pm
by RobertGonzalez
So I am trying to roll out a new server. Two actually, and our enterprise server is Sybase. I have had all sorts of weird problems hitting Sybase in the past, and each time I was able to overcome my problems with the help of this community, Google and a lot of chocolate.

Here is my latest issue.

I have compiled a modified Sybase CT extension that allows for multiple result set handling. This same extensions has been compiled on our other servers with some headache, but ultimately, successfully.

This time around the extension compiled with not a single problem. Three minutes and done, and I have a sybase_ct extension. My problem is that from a web server, the sybase_connect() function fails immediately. It doesn't return an error, it just prompts you to download the test file. But from the CLI, the sybase_connect function works without a hitch.

When run from the web, I get the following error message:
PHP Warning: sybase_connect() [<a href='function.sybase-connect'>function.sybase-connect</a>]: Sybase: Unable to allocate connection record in /path/to/sybase/test.php on line 24
Line 24 (and the next few lines) looks like this:

Code: Select all

<?php
if (!$con = sybase_connect('SERVER', 'USER', 'PASSWORD'))
{
    die('Could not contact the DB server: ' . sybase_get_last_message());
}
?>
However, when I do this at the CLI:

Code: Select all

[root@server /]# php -r 'sybase_min_server_severity(16); $con = sybase_connect("SERVER", "USER", "PASSWORD"); var_dump($con); var_dump(sybase_query("sp_who"));'
I get this:

Code: Select all

resource(4) of type (sybase-ct link)
resource(5) of type (sybase-ct results)
Does anyone have any idea why it would work at the CLI and not as an Apache module? I have checked and rechecked permissions, file placement, environment vars, paths... everything. I have googled the hell out of this error message and tried some of the stuff some people have mentioned. Still, it is a no go through the web.

FYI, I am using PHP 5.1.6 (also on the machines that this is working on), Apache 2.0.59 (again, same as the machines it is working on) and Sybase client 12.5 (same as the others). Any help in connecting to my database server would be much appreciated.

Posted: Tue Dec 04, 2007 9:46 am
by RobertGonzalez
I figured this out. The reason that things worked from the CLI and not from the web server is that the environment variable were different in each environment. From the CLI the ENV variable were adopted from what was loaded into the system at boot time. For some reason the Apache environment variables, including LANG (this is key in this circumstance because without a set LANG variable Sybase pukes on deciding which way to go).

My solution was:

Code: Select all

root@systems ~]# apachectl stop
root@systems ~]# export LANG
root@systems ~]# apachectl start
Done. Quite literally the only variance between the two systems were the ENV variables. Now everything is the same.