Crazyfig Posted March 30, 2011 Share Posted March 30, 2011 Hi all, Been struggling for 2 days now. Installed WAMP with Apache 2.2. PHP runs fine, but I cant connect to MSSQL. The mssql extension is uncommented in php.ini, and the dll exists in the 'ext' directory (see attached images). Everything seems to be fine, and where it should be....but it cant connect to MSSQL. Its not the servername, username or password...it it were it would be a different message....this is saying mssql is not installed when it clearly is? I know MSSQL is not installed by running code below: if (function_exists('mssql_connect')){ echo "Okay, fn is there<br>------------------<br>"; } else { echo "Hmmm .. fn is not even there<br>------------------<br>"; } if(extension_loaded("mssql")) { echo "MSSQL is Loaded<br>"; } else { echo "MSSQL not loaded<br>"; } if(extension_loaded("msql")) { echo "MSQL is Loaded<br>"; } else { echo "MSQL not loaded<br>"; } echo '<br><br>'; $ext = get_loaded_extensions(); if(in_array('mssql', $ext)) echo 'u have mssql installed<br><br>'; else echo 'u do NOT have mssql installed<br><br>'; Above displays: Hmmm .. fn is not even there ------------------ MSSQL not loaded MSQL not loaded u do NOT have mssql installed Extensions from php.ini ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_dba.dll ;extension=php_exif.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll ;extension=php_ming.dll extension=php_mssql.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ;extension=php_oci8_11g.dll ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phar.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite.dll ;extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll extension=php_pdo_mssql.dll extension=php_pdo_sqlsrv_52_nts_vc6.dll extension=php_msql.dll extension=php_dblib.dll extension=php_sqlsrv_53_ts_vc9.dll extension=php_pdo_sqlsrv_53_ts_vc9.dll ;extension=php_pdo_sqlsrv_52_ts_vc6.dll ;extension=php_pdo_sqlsrv_52_ts_vc6.dll ;extension=php_pdo_sqlsrv_52_ts_vc6.dll ;extension=php_pdo_sqlsrv_52_ts_vc6.dll ;extension=php_sqlsrv_52_ts_vc6.dll extension=php_pdo.dll Extension directories from phpinfo.php Configuration File (php.ini) Path C:\windows Loaded Configuration File C:\wamp\bin\apache\Apache2.2.17\bin\php.ini I set debug to true, ran code that tries to connect to a mssql server, get error message below: Fatal error: Call to undefined function mssql_query() in C:\wamp\www\website\include\adodb\drivers\adodb-mssql.inc.php I have the ntwdblib.dll file in the root php folder (as seen in the attached images, correct version....its the older one...not the newer one which apparently gets corrupted), so all is as it should be...but I still cant connect! Please help....have search the net but everything I try doesnt seem to help [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/232164-setup-issue-php-apache-and-mssql-cant-find-mssql/ Share on other sites More sharing options...
corbin Posted March 30, 2011 Share Posted March 30, 2011 Hi... mSQL != MSSQL, so using the mSQL extension makes no sense. Additionally, unless your code has some existing dependency on the MSSQL extension (mssql_* functions), you should be using MS's extension http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx If you do have code depedent on mssql_*, I suggest recoding it, but if it's a big project that might not be possible. Anyway, php_mssql.dll depends on a dll originally in MSSQL 2000 (I don't think the DLL exists in SQL Serv 2005/2008). I don't remember what the DLL is called, unfortunately, and I have no idea where to get it these days. Anyway, you'll likely want to run PHP from the command line or check the Apache error log to see exactly why the extension's not loading. (Also, on a semi related note: I usually use PDO for MSSQL related stuff [actually all DB related stuff, really]. That way it's easier to switch between mssql extensions if need be.) Quote Link to comment https://forums.phpfreaks.com/topic/232164-setup-issue-php-apache-and-mssql-cant-find-mssql/#findComment-1194413 Share on other sites More sharing options...
Crazyfig Posted March 30, 2011 Author Share Posted March 30, 2011 Hi... mSQL != MSSQL, so using the mSQL extension makes no sense. Ok, thanks for the info, I added the ";" back in front in php.ini Additionally, unless your code has some existing dependency on the MSSQL extension (mssql_* functions), you should be using MS's extension http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx If you do have code depedent on mssql_*, I suggest recoding it, but if it's a big project that might not be possible. Anyway, php_mssql.dll depends on a dll originally in MSSQL 2000 (I don't think the DLL exists in SQL Serv 2005/2008). I don't remember what the DLL is called, unfortunately, and I have no idea where to get it these days. Yeah, have code dependent on mssql and to recode, damn...it really is not an option now The DLL it depends on is called ntwdblib.dll. There is a 2004 version(incorrect one) and a 2000 version(correct version). I am using the correct version from SQL 2000. Anyway, you'll likely want to run PHP from the command line or check the Apache error log to see exactly why the extension's not loading. Checked the Apached error log, no more errors....just warnings now: PHP Warning: PHP Startup: mssql: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: mssql: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in <b>Unknown</b> on line <b>0</b><br /> PHP Warning: PHP Startup: pdo_mssql: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: pdo_mssql: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in <b>Unknown</b> on line <b>0</b><br /> PHP Warning: PHP Startup: pdo_mssql: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: pdo_mssql: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in <b>Unknown</b> on line <b>0</b><br /> PHP Warning: PHP Startup: mssql: Unable to initialize module\nModule compiled with build ID=API20090626,TS,VC9\nPHP compiled with build ID=API20090626,TS,VC6\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: mssql: Unable to initialize module Module compiled with build ID=API20090626,TS,VC9 PHP compiled with build ID=API20090626,TS,VC6 These options need to match in <b>Unknown</b> on line <b>0</b><br /> PHP Warning: PHP Startup: PDO: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: PDO: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in <b>Unknown</b> on line <b>0</b><br /> PHP Warning: PHP Startup: mssql: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0 <br /> <b>Warning</b>: PHP Startup: mssql: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in <b>Unknown</b> on line <b>0</b><br /> [Wed Mar 30 19:45:15 2011] [notice] Child 4132: Child process is running (Also, on a semi related note: I usually use PDO for MSSQL related stuff [actually all DB related stuff, really]. That way it's easier to switch between mssql extensions if need be.) I think I will need to use the Microsoft solution. I tried this, but had no luck...guess its time to try again! Quote Link to comment https://forums.phpfreaks.com/topic/232164-setup-issue-php-apache-and-mssql-cant-find-mssql/#findComment-1194439 Share on other sites More sharing options...
Crazyfig Posted April 1, 2011 Author Share Posted April 1, 2011 UPDATE: Well, I have to say Im not impressed with WAMP at all. Added...I tried EasyPHP (similar to WAMP) and had no luck either. I then tried the MSI installed from php.net....surprise...same result...no luck. PHP runs in all, dont get me wrong....but with errors and warnings all over the place. BUT! I found a way to get it all working...not ideal...but its running - PHP, IIS 7.5 and SQL Server. Now I can run ASP pages and PHP pages all from the same location. I did the manual install....pretty much as below: My step by step process: [*]Install PHP 5.2 from zip file downloaded from php.net [*]Save to C:\php [*]In php.ini add the following configuration setting: cgi.force_redirect = 0. This is the minimum setting you need to change to make PHP work with IIS. You may also want to use cgi.fix_pathinfo = 1, fastcgi.impersonate = 1, and set ext_dir.\ [*]Install IIS (Running with IIS 7 / 7.5) [*]Activate the World Wide Web Services/Application Development Features/CGI node and also Web Management Tools/IIS Management Console. [*]Now, start the IIS Management Console. There, navigate to the Sites/Default Web Site/Handler Mappings node and double-click on the "Handler Mappings" entry. [*]As a result of this, the Actions panel on the right hand side changes. You now see an option called Add Module Mapping. Clicking on it opens up a dialog which you fill out as you can see in the following figure - PIC 1 (you may need to adapt the path used to your local system). [*]If you do not see the FastCgiModule entry, you probably forgot to check the CGI node when installing IIS. Otherwise, close the Add Module Mapping dialog by clicking on OK. You need to confirm that you want to create a FastCGI application; click Yes. [*]Finally, create a .php script and put it in the root folder of the IIS site (by default C:\Inetpub\wwwroot; note that you may need additional rights to write into that directory), e.g. phpinfo.php with a simple phpinfo() call in it. Call this script using http://localhost/phpinfo.php. PHP installed and running. Continue below for SQL Server extension setup... [*]Stop IIS [*]Go to php.ini and uncomment extension=php_mssql.dll. [*]Make sure ntwdblib.dll is as per version below. It must reside in the php folder - PIC 2. [*]Update E_ALL to E_ERROR. [*]Restart IIS, and check database can connect. Should be working now! I hope this helps someone, because I have pretty much wasted this week trying to get this working....projects have been delayed....its been a real frickin mess. I have now saved the above every-frickin-where....so it will never get lost and this wont happen again!! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/232164-setup-issue-php-apache-and-mssql-cant-find-mssql/#findComment-1195435 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.