This is a form letter that I send out to the numerous folks who contact me with problems getting Sybase / Apache / Win2000 / PHP to work together sucessfully. It has been 100% successful so far for all although sometimes it has taken a follow-up e-mail or two to correct misunderstadings of the instructions.
Unfortunately I cannot leave the sample files which I include as attachments in this responce area. So, if you need help you'll have to contact me so that I can send you the files.
What I really wish is that the folks here at PHP.NET would include the corrections in their release downloads so that people would no longer be confronted with these problems.
==========================================
Prescription for getting PHP working with Apache and Windows 2000.
Download only from http://www.php.net/ PHP 4.0.4. (downloads from other sites like http://www.php4win.de. include additional problems)
Place the following file in the c:\php4\extensions sub-directory where it will replace the existing php_sybase_ct.dll file.
(php_sybase_ct.dll file attachment cannot be placed here so you will have to contact me for it)
Until you get things going and tested use the the PHP.INI and Apache configuration files that I have attached (not included here / you'll have to contact me). Once you get it to work you can go back and modify these two files to your hearts content knowing full well that you can back up into the ones that I sent you if things stop working. The PHP.INI goes in your Windows or WINNT directory. The httpd.conf goes in the Apache conf sub-directory under your Apache directory. You may have to dump the contents of your c:\PHP4\ini subdirectory into the main c:\PHP4 directory.
The following file should display your test your php configuration along with the sybase_ct settings.
(attachment not included here)
That should get you properly configured and provide for a connection.
After you connect you will continue to get warning messages and here
is what you can do about them.
(Warning messages in an attachment)
The messages are just warnings, and if you change your min.severity level in you php.ini file you will get rid of them.
I guess you will find the following in the sybase ct section of your php.ini file.
sybct.min_server_severity = 10 ; minimum server message severity to display
sybct.min_client_severity =10 ; minimum client message severity to display
and if you change them to
sybct.min_server_severity = 11 ; minimum server message severity to display
sybct.min_client_severity = 11 ; minimum client message severity to display
they should go away.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Also another solution to the warning messages is as follows:
Write
if($liLink = @sybase_connect("myserver", "myuid", "mypwd"))
instead of
if($liLink = sybase_connect("myserver", "myuid", "mypwd"))
in your PHP scripts.
Directory settings and locations are important. For now make them as described
in the following. You can change them once you get things going. Directory locations
are referenced in the scripts and must match for this to work.
To make the above work my Sybase was installed on my Win2000 computer
in the C:\Sybase directory. I used version 11.9.2 but 12.0 works as well.
PHP was installed in a C:\PHP4 directory.
The Apache conf is installed in C:\Program Files\Apache Group\Apache\conf
If the Sybase server is up and going in Sybase Central the script which follows
will make a connection.
Sample database script
<?php
// create connection
$connection = sybase_connect("YOURSERVER","sa","PASSWORD")
or die("Couldn't make connection.");
// select database
$db = sybase_select_db("master", $connection)
or die("Couldn't select database.");
...... do what ever queries or updates ......
// free resources and close connection
sybase_free_result($sql_result);
sybase_close($connection);
?>
Connect to the following location for further instructions and examples:
http://www.thickbook.com/extra/php_sybase.phtml
////////////// Stop Here and try the above which has pretty much worked for everyone so far. ////////////////////
Once you get the above to work then read on and try other things if you wish.
Two methods of connecting to Sybase / PHP.
Connecting to Sybase through PHP by using Open Client.
When you are using PHP together with Apache there are two ways to do this. You can either use it as CGI ( Common Gateway Interface ), which is proved in the scripts above, or you can use it as an Apache
module. On the windows operating system, CGI is, or at least it was, the most stable one.
If you are using the ScriptAlias method, you are using CGI, if you are using the LoadModule option you are using PHP as a module.
When you are using the CGI option, apache is using the php.exe to run all you php files. This means that when you are requesting a
php-file from the webserver, it will take that file and send is an "argument" to the php.exe, run it, capture the output and sent to the web were you will se the result.
When you are using the module option, php (sort of) becomes a part of the Apache Web server. This means that your request for php-files will be interpreted "much" faster. Apache does not have to start an "outside" application to interpret your request.
Unfortunately it seems like the php_sybase_ct.dll file we made
often generates a "crash" in the apache.exe file if you are using php as a module in Apache versions prior to v. 1.3.17.
If you are using cgi everything works fine. If this is due to a problem in the php_sybase_ct.dll or a problem in the php4apache.dll.
The funny thing is that with Apache v. 1.3.17 on windows everything
seems to work just fine with LoadModule.
I know this was a problem with 1.3.12/1.3.14.
If you want to try to run php as an apache module on windows you would have to remove/comment out everything regarding php in your httpd.conf file, and implement these lines.
#PHP4 MODULE SETUP
LoadModule php4_module modules/php4apache.dll
<FilesMatch ".*.(php4|php3|php)$">
ForceType application/x-httpd-php
</FilesMatch>
Hope this made things a little bit clearer
==========================================
My name is Sheridan Martin and I work for NYS Dept. of Health as a Database Programmer / Analyst.
sjm05@health.state.ny.us
Two additional contributors who helped make this solution possible are the follows:
Tor-Egil Nygaard <Tor-Egil.Nygaard@exense.com>
Fabien Reygrobelle < "fabien@usa.net" >