newphpcoder Posted October 5, 2010 Share Posted October 5, 2010 Good day!I’m here again posting about my problem in the connection of mssql to php.I have a problem in my connection in mssql to php. I tried my best to fix my problem. Here is some data I could give for better understanding.I used:SQL Server 2005 ExpressSQL Server Management Studio ExpressIIS 6.0php 5.2.4I configure my php.iniI uncommented the following:cgi.force_redirect = 0doc_root = “C:\Inetpub\wwwroot”extension=php_mssql.dllmssql.secure_connection = OnI change my ntwdlib.dll version from 2000.2.8.0 to 2000.80.194.0 because I found out that my older version of ntwdblib.dll was not work in sql server 2005 so I search for a ntwdblib.dll version that work on sql server 2005. So I deleted the old version and I put the new version of ntwdblib.dll in Windows/System32, php folder, and in php/ext folder.And this is my information in my SQL Server:Server Type: Database EngineServer name: ISM\SQLEXPRESSAuthentication: Windows AuthenticationUsername: MR\Administrator ----This username was hidingPassword: ----Password was hidingI have a big question in my mind and it is what username and password I could use in php to connect in mssql if the username and password is hiding. I try to use the sa and its password, but I don’t know if it is right. And also I try the MR\Administrator as username and the password is blank, but sad to say still I can’t connect.Here is my code: <?php//mssql.secure_connection = On// Need to upload ntwdblib.dll from net$myServer = “ISM\SQLEXPRESS”; // host/instance_name$myUser = “sa”; // username$myPass = “xoxoxo″; // password$myDB = “dbtest”; // database name// connection to the database$dbhandle = mssql_connect($myServer, $myUser, $myPass)or die(“Couldn’t connect to SQL Server on $myServer”);// select a database to work with$selected = mssql_select_db($myDB, $dbhandle)or die(“Couldn’t open database $myDB”);echo “You are connected to the ” . $myDB . ” database on the ” . $myServer . “.”;?> After I run this code, the result is:Fatal error:Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\testconn.php on line 11I don’t know what the problem is and what the configurations I need to do are.I hope somebody can suggest or help me to fix my problem, because I really need to fix it.Thank you in advance… Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2010 Share Posted October 5, 2010 If the function is undefined then the mssql extension in PHP is not enabled. You need to enable that extension in php.ini and restart the server. Link to comment Share on other sites More sharing options...
newphpcoder Posted October 6, 2010 Author Share Posted October 6, 2010 If the function is undefined then the mssql extension in PHP is not enabled. You need to enable that extension in php.ini and restart the server.I already enabled the extension of mssql in my php.ini and also i restarted the server but still I cannot connect.Thank you Link to comment Share on other sites More sharing options...
Guest brian_swan Posted October 6, 2010 Share Posted October 6, 2010 When you execute a script that calls phpinfo(), does the output show that the mssql driver is loaded? The only reason (that I know of) for getting the "called to undefined function mssql_connect" is that the mssql driver isn't loaded.As a side note, since your are running on Windows, I'd suggest you use the sqlsrv driver. I've written about the differences between the mssql and sqlsrv drivers here:http://blogs.msdn.com/b/brian_swan/archive...nce-part-1.aspxhttp://blogs.msdn.com/b/brian_swan/archive...nce-part-2.aspx Hope that helps.-Brian Link to comment Share on other sites More sharing options...
justsomeguy Posted October 6, 2010 Share Posted October 6, 2010 I already enabled the extension of mssql in my php.ini and also i restarted the server but still I cannot connect.Is the error message the same? Because this is not a connection issue:Fatal error:Call to undefined function mssql_connect()That means the function doesn't even exist, not that you just can't connect. It's not able to even try connecting in the first place because the function to do so doesn't exist. The only reason the function would not exist is if the extension was not enabled. Make a phpinfo page so you can verify that you're editing the correct php.ini file. Link to comment Share on other sites More sharing options...
newphpcoder Posted October 7, 2010 Author Share Posted October 7, 2010 Is the error message the same? Because this is not a connection issue:Fatal error:Call to undefined function mssql_connect()That means the function doesn't even exist, not that you just can't connect. It's not able to even try connecting in the first place because the function to do so doesn't exist. The only reason the function would not exist is if the extension was not enabled. Make a phpinfo page so you can verify that you're editing the correct php.ini file.I am confuse about what the phpinfo display is differen in my php.ini like the extension_dir in phpinfo is C:\php5 and in my php.ini the extension_dir is extension_dir = ".\ext"And also the mssql was not in the phpinfo() Link to comment Share on other sites More sharing options...
justsomeguy Posted October 7, 2010 Share Posted October 7, 2010 It sounds like it's using a different php.ini. Near the top of the phpinfo page you'll see a "Configuration file" field that shows the php.ini that it loaded. Link to comment Share on other sites More sharing options...
newphpcoder Posted October 7, 2010 Author Share Posted October 7, 2010 It sounds like it's using a different php.ini. Near the top of the phpinfo page you'll see a "Configuration file" field that shows the php.ini that it loaded.my php version is php 5.2.4..You mean all the configuration that i do in my php.ini will reflect in phpinfo()? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 7, 2010 Share Posted October 7, 2010 All of the configuration that you do in the php.ini that is actually being loaded will be reflected, yes. The phpinfo page will tell you exactly which php.ini PHP is actually using. This lists the locations that PHP will look for it:http://www.php.net/manual/en/configuration.file.php Link to comment Share on other sites More sharing options...
newphpcoder Posted October 8, 2010 Author Share Posted October 8, 2010 All of the configuration that you do in the php.ini that is actually being loaded will be reflected, yes. The phpinfo page will tell you exactly which php.ini PHP is actually using. This lists the locations that PHP will look for it:http://www.php.net/manual/en/configuration.file.php Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.