Hezine
Hezine

Reputation: 23

Having some trouble php connection string to a mssql server

I been working game that use MSSQL but I have been having trouble with the connection as it keep coming back as undefined.

I don't know much about PHP and a friend helped me setup the server. It's Apache 2.2

$serveruser ="user";
$serverPass = "pass";
$server = "server";

$con = mssql_connect($server, $serveruser, $serverPass);

if (!$con)
    die('Could not connect:');

Upvotes: 0

Views: 89

Answers (2)

Maulik patel
Maulik patel

Reputation: 2442

$host="localhost";
$username="root";
$password="";
$dbhandle = mysql_connect($host, $username, $password);
$selected = mysql_select_db("database name",$dbhandle);
if($selected){
    echo "buuraaaa.....my database is selected \o/";
}
else    {
  echo "ohh,,,no its not selected";
}

Upvotes: 0

sanjeet sharma
sanjeet sharma

Reputation: 23

The basic syntax of connection is :-

 mssql_connect("localhost<host name>", "<username>", "<password>");

check your hostname, username and password.

Upvotes: 0

Related Questions