/    Sign up×
Community /Pin to ProfileBookmark

connection from php to mssql

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 Express
SQL Server Management Studio Express
IIS 6.0
php 5.2.4

I configure my php.ini
I uncommented the following:

cgi.force_redirect = 0
doc_root = “C:Inetpubwwwroot”
extension=php_mssql.dll
mssql.secure_connection = On

I 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 Engine
Server name: ISMSQLEXPRESS
Authentication: Windows Authentication
Username: MRAdministrator —-This username was hiding
Password: —-Password was hiding

I 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 MRAdministrator as username and the password is blank, but sad to say still I can’t connect.

Here is my code:

[code=php]
<?php
//mssql.secure_connection = On
// Need to upload ntwdblib.dll from net
$myServer = “ISMSQLEXPRESS”; // host/instance_name
$myUser = “sa”; // username
$myPass = “xoxoxo&#8243;; // 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 . “.”;
?>
[/code]

After I run this code, the result is:

Fatal error:Call to undefined function mssql_connect() in C:Inetpubwwwroottestconn.php on line 11

I 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…

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@Mahmood_AkhtarOct 06.2010 — Try 11th line as given below:

$selected = mssql_select_db($myD? or die(“Couldn’t open database $myDB”);

Mahmood.
Copy linkTweet thisAlerts:
@rhodaroseauthorOct 07.2010 — Try 11th line as given below:

$selected = mssql_select_db($myD? or die(“Couldn’t open database $myDB”);

Mahmood.[/QUOTE]



I try the code that you suggested but still I can't connect the error:

[code=php]
<?php
//mssql.secure_connection = On
//need to upload ntwdblib.dll from net

$myServer = "ISMSQLEXPRESS";
//$connectionOptions = array("Database" => "AdventureWorks");
$myUser = "MRMAdministrator";
$myPass = "xoxoxo";

//Connection to the database
$dbhandle = mssql_connect($myServer,$muUser,myPass) or die("Could not connect to SQL Server");

//Select a database
$seleected=mssql_select_db($myDB) or die("Could not open database");

echo "You are connected";
?>
[/code]

Fatal error: Casll to undefined mssql_connect() in C:Inetpubwwwroottestconn.php on line 12
Copy linkTweet thisAlerts:
@Mahmood_AkhtarOct 07.2010 — Here is the original code, I use to connect to a database:

[CODE]<?
session_start();


$dbcon = mysql_connect('localhost', 'raees', 'mughal') or die('Unable to Connect to DB server');

$my_db = mysql_select_db('mahmood_inspexs');

?>[/CODE]


and it ever works fine...
Copy linkTweet thisAlerts:
@criterion9Oct 07.2010 — I try the code that you suggested but still I can't connect the error:

[code=php]
<?php
//mssql.secure_connection = On
//need to upload ntwdblib.dll from net

$myServer = "ISMSQLEXPRESS";
//$connectionOptions = array("Database" => "AdventureWorks");
$myUser = "MRMAdministrator";
$myPass = "xoxoxo";

//Connection to the database
$dbhandle = mssql_connect($myServer,$muUser,myPass) or die("Could not connect to SQL Server");

//Select a database
$seleected=mssql_select_db($myDB) or die("Could not open database");

echo "You are connected";
?>
[/code]

Fatal error: Casll to undefined mssql_connect() in C:Inetpubwwwroottestconn.php on line 12[/QUOTE]

Do you have the mssql dll? Did you restart the service?
Copy linkTweet thisAlerts:
@rhodaroseauthorOct 08.2010 — Do you have the mssql dll? Did you restart the service?[/QUOTE]
Yes, I have mssql.dll in my php.ini and I uncomennted it.And also i restart my service.
Copy linkTweet thisAlerts:
@rhodaroseauthorOct 08.2010 — Here is the original code, I use to connect to a database:

[CODE]<?
session_start();


$dbcon = mysql_connect('localhost', 'raees', 'mughal') or die('Unable to Connect to DB server');

$my_db = mysql_select_db('mahmood_inspexs');

?>[/CODE]


and it ever works fine...[/QUOTE]


I'm not using mysql i used mssql
×

Success!

Help @rhodarose spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...