Author |
Topic |
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-05 : 06:33:58
|
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]<?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 . “.”;?>[/php]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… |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-05 : 08:45:31
|
is ntwdblib installed? And PATHed?is php_mssql.dll in the ext folder? |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-05 : 19:52:10
|
quote: Originally posted by russell is ntwdblib installed? And PATHed?is php_mssql.dll in the ext folder?
I did not install the ntwdblib i only put it on the windows/system32, php folder and also on the ext folder.What do you mead PATHed?Yes the php_mssql.dll is in ext folder. |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-05 : 20:10:28
|
The PATH environment variable in windows makes an executable accessible from anywhere on the machine. Basically, it allows an application to call an executable without "knowing" the exact location of the executable.See here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/path.mspx?mfr=truePretty sure that ntwdblib needs to be installed (registered) to be used.Have a look at this, which I googled out based on the specific error you're getting: http://www.phpfreaks.com/forums/index.php?topic=197064.0 |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-06 : 01:15:13
|
They say that it's better to move my php folder in windows path. but they also suggest that in the extension_dir i put "C:\php\ext".What I'm going to do? |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-06 : 15:13:28
|
you don't move it to put it in the path. you put it in the environment path variable |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-07 : 00:49:29
|
How can I install the ntwdblib.dll? |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-07 : 00:52:08
|
quote: Originally posted by russell you don't move it to put it in the path. you put it in the environment path variable
I already put the path of php in the system variable. |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-07 : 01:15:44
|
I do all the configuration that i know to work my connection from php to mssql like this:1.I put the php location in the system variable PATH.2.I download the ntwdblib.dll version that work in sql server 2005.3.I put the ntwdblib.dll in the system32, and php folder.3.I configure my php.ini I uncommented the ff: extension=php_mssql.dll extension_dir=".\ext" doc_root ="C:\Inetpub\wwwroot" cgi.force_redirect = 0 mssql.secure_connection = OnI change also my php code:<?php//mssql.secure_connection = On//Need to uplaod ntwdblid.dll from net$myServer="ISM\SQLEXPRESS";//$connectionOptions=array("Database"=>"AdventureWorks");//$myUser = "MRM\Administrator";//$myPass = "xoxoxo";$myDB = "dbtest";//Connect to the database$dbhandle = mssql_connect($myServer) or die("Could not connect to SQL Server");//Select a database$selected = mssql_select_db($myDB) or die("Could not open database");echo "You are connected to the dbtest";?> After all this configuration still I can't connect to mssqlFatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\testconn.php on line 12 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-07 : 10:13:40
|
register ntwdblib.dll |
|
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-07 : 21:00:47
|
quote: Originally posted by russell register ntwdblib.dll
How can I register ntwdblib.dll? |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-10-08 : 10:07:02
|
in a command window, navigate to the system32 foldercd \ cd windows\system32 then use regsvr32 to register the dllregsvr32 ntwdblib.dll |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
newphpcoder
Starting Member
23 Posts |
Posted - 2010-10-10 : 20:58:42
|
quote: Originally posted by russell in a command window, navigate to the system32 foldercd \ cd windows\system32 then use regsvr32 to register the dllregsvr32 ntwdblib.dll
I try this and the result is:ntwdblib.dll was loaded,but the DllRegister entry point was not found.This file can not be registered. |
|
|
|