Paper Tiger Posted February 2, 2010 Share Posted February 2, 2010 Ok, they say the best place to start is at the beginning so I shall. Yesterday I decided I would install IIS. However I discovered that Vista Home Basic doesn't come with IIS so I went for Apache. Apache installed just fine and ran fine once I'd figured out that I needed to set "Listen 192.160.0.2:80" in the conf file. Then I decided to install php. I followed the instructions and PHP works fine in Apache - phpinfo() tells me lots of interesting things that I haven't fully read yet. Seeing as I already had MS SQL Sever 2008 Express installed I decided to use this instead of installing MySQL as well. I created a new database with a single table for testing purposes and created a login called "testUser" with password "testPassword" and then created an account for the testDB linked to the testUser login I had created. so now I had my server name "./SQLEXPRESS" my username "testUser" and the password "testPassword" all set up in my php file to test the database connection. $dbuser="testUser"; $dbpass="testPassword"; $dbname="test"; //the name of the database echo "Attempting Connect<br />"; $chandle = mssql_connect(".\SQLEXPRESS", $dbUser); if (!$chandle) {die('Something went wrong while connecting to MSSQL');} echo "<p>Got Connection!</p>"; That's the code I'm using to simply test the connection. I found that the mssql_connect() function was doing nothing, not even an error code. I found out that for some reason my installation of php had none of the MSSQL extensions installed so I located the latest versions of ntwdblib.dll and php_mssql.dll and changed php.ini to include the lines: [php_MSSQL] extension=php_mssql.dll ntwdlblib.dll is sitting in my system32 directory and php_mssql.dll is in the "c:\php\ext" however this time when I restarted Apache it simply crashed. No error message, I just g0t the windows message saying that Apache had encountered an error and had to close. If I comment out the line which includes the mssql extension in php.ini then Apache starts up fine. This is the tail of my error.log in Apache *here "extension=php_mssql.dll" in php.ini is commented out - server starts fine* Starting the Apache2.2 service The Apache2.2 service is running. pid file C:/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? Starting the Apache2.2 service The Apache2.2 service is running. pid file C:/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Mon Feb 01 23:50:41 2010] [notice] Apache/2.2.14 (Win32) PHP/5.3.1 configured -- resuming normal operations [Mon Feb 01 23:50:41 2010] [notice] Server built: Sep 28 2009 22:41:08 [Mon Feb 01 23:50:41 2010] [notice] Parent: Created child process 3316 [Mon Feb 01 23:50:42 2010] [notice] Child 3316: Child process is running [Mon Feb 01 23:50:42 2010] [notice] Child 3316: Acquired the start mutex. [Mon Feb 01 23:50:42 2010] [notice] Child 3316: Starting 64 worker threads. [Mon Feb 01 23:50:42 2010] [notice] Child 3316: Starting thread to listen on port 80. *Apache is runing - I put "extension=php_mssql.dll" back into php.ini and issue the Apache restart command* [Mon Feb 01 23:52:25 2010] [notice] Parent: Received restart signal -- Restarting the server. [Mon Feb 01 23:52:25 2010] [notice] Child 3316: Exit event signaled. Child process is ending. [Mon Feb 01 23:52:26 2010] [notice] Child 3316: Released the start mutex [Mon Feb 01 23:52:27 2010] [notice] Child 3316: All worker threads have exited. [Mon Feb 01 23:52:27 2010] [notice] Child 3316: Child process is exiting [code] As you can see there are no further messages of any kind when the server attempts to restart, it simply crashes. I can't be sure if this is a problem with Apache or PHP or the extension dll, I'm inclined to suspect it's a faulty php_mssql.dll but if anyone has spotted anything obvious to the more learned eye please let me know. Not stressed yet though just mildly annoyed. Quote Link to comment Share on other sites More sharing options...
Paper Tiger Posted February 2, 2010 Author Share Posted February 2, 2010 I just had a minor revelation after posting - amazing how explaining what you've done can do that to you - I wondered if I had the right version of the extension. Turns out NO. I had a version not compatible with PHP 5.3 VC9 Just in case anyone else has the same problem then a dll compiled for PHP 5.3 VC9 can be found here: http://rapidshare.com/files/262914922/php_mssql.dll What I get now is a "Failed to connect" error message but at least that means that PHP and Apache and the MSSQL extension are playing nicely now. I'll chew over connecting to the database properly tomorrow and come back if I really can't work it out. Thanks for reading. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 2, 2010 Share Posted February 2, 2010 What method did you use to obtain and install php? If you used the .zip package (the recommend method) ALL the same version of the .dll files are included. Best guess is that you installed php using the .msi installer? If so, you are expected to install extensions using the Windows control add/remove php item. Next, in your master php.ini, set error_reporting to E_ALL and display_errors to ON so that php will display all the errors it detect. This will save you a ton of time during the learning, development, and debugging cycle. Stop and start your web server to get any change made to php.ini to take effect and confirm the two settings using a phpinfo(); statement (in case the php.ini that you are changing is not the one that php is using.) Edit: if you echo mssql_get_last_message() after any mssql_ function call that fails, it should give you some debugging information. Quote Link to comment Share on other sites More sharing options...
Paper Tiger Posted February 2, 2010 Author Share Posted February 2, 2010 Hi, yes, I did use the MSI installer. However I am not seeing an add/remove php item control anywhere. Not in control panel nor in the start menu group for PHP. Checked php ini again and error_reporting = E_ALL & E_DEPRECATED, display_errors was Off so I changed that to On. Thanks for the tips 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.