Manakin
Manakin

Reputation: 3

Getting mssql_connect() error even though I have the drivers

this is something I've really been losing sleep over, so I'd be very thankful if anyone could help me.

So, I'm trying to set up a launcher for a game. I have a Login.php on my web server and the launcher in Visual Studio. When pressing "Start" it connects to Login.php where it checks if the game login credentials are correct, if they are, it should return a string of random letters (a token) to the Launcher. The Login.php tries to connect to my database in SQL Server 2008.

Now to the problem, I get

Fatal error: Call to undefined function mssql_connect() in C:\inetpub\wwwroot\Login.php on line 12

when trying to go to the website manually (By entering 127.0.0.1/Login.php into the browser.). And when I try to run the program and press start, it returns a 500 Internal Error.

I have googled the mssql error and found out that the mssql functions have been removed from the newer versions of PHP, so I downloaded the drivers from Microsoft and enabled them in the PHP Manager on IIS 7.5.

The version of PHP I use is 5.4.25 and I enabled these drivers:

php_pdo_sqlsrv_54_nts.dll
php_sqlsrv_54_nts.dll

And here are the first 13 lines of the Login.php:

<?php

$conf['db_host'] = "GERA044\SQLEXPRESS";
$conf['db_user'] = "sa";
$conf['db_pass'] = "L4sfa445AdxDDLfor95";
$conf['db_name'] = "Account";

$user = sql_clean($_GET['Username']);
$passhash = sql_clean($_GET['Password']);


$con = mssql_connect($conf['db_host'],$conf['db_user'],$conf['db_pass']) or die('Database connect Fail.');
$db = mssql_select_db($conf['db_name'], $con) or die('Database Init Fail.');

In short: I still get an mssql error even though I have the drivers.

Hopefully someone can find a solution to the problem here, Thank you!

Upvotes: 0

Views: 293

Answers (1)

yannis
yannis

Reputation: 6345

php_sqlsrv_54_nts.dll is the SQLSRV extension, not the MSSQL one. You should use the sqlsrv_* family of functions instead of the mssql_* one.

Upvotes: 1

Related Questions