PDA

Click to See Complete Forum and Search --> : connecting to mssql


lerroux
Apr 29th, 2009, 04:51 AM
hi,

i have a mssql server 2005 database on a windows server 2003 machine and would like to connect to it from my php webserver which is a centos based server.

i tried the mssql_connect() from my php code and it gave me the error:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: {sql server ipaddress}

i installed wamp on my winxp workstation and tried it there. got the same error.

i can connect to the sql server from my winxp using the sql dev studio.

i also tried to google and found several workarounds:

i'm sure php.ini has extension=php_mssql.dll and mssql.secure_connection = Off

and i also have ntwdblib.dll in all directories, system32, apache2/bin, php

no use.

still got the same error

help!

cheers,
lerroux

kows
Apr 29th, 2009, 05:10 AM
post your code? you aren't seriously trying to connect to "{sql server ipaddress}," are you? (hopefully, you just removed your IP address from being paranoid!)

make a phpinfo file (file containing a call to the phpinfo() function) and make sure that the MSSQL extension is actually registering. you should be able to do a find on the page and search for "mssql." if nothing is found, then the extension isn't being loaded.

lerroux
Apr 29th, 2009, 05:30 AM
<?php
$myServer = "ipaddress";
$myUser = "myuname";
$myPass = "mypassword";
$myDB = "ARIAL1";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Unable able to connect to $myServer");

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");

?>


got that code from other forums. seems to be working for them.

BrianS
May 1st, 2009, 12:13 PM
They probably put in their IP address where it says "ipaddress", along with their username and password for the DB.

lerroux
May 6th, 2009, 07:12 AM
i know that. i just replaced it with ipaddress so that i wont be posting my real ip address here...

anyone know how i get around with this?

Anrui
May 8th, 2009, 09:46 AM
I am also running into the same problem right now. My development box (WAMP) won't talk to the MSSQL box, but my SQL Client (Squirrel) does just find. Also, the ODBC connection test in Vista works, as well.

I've tried the new DLL, checking to make sure the information is listed in PHPInfo, and even a couple other things, but I'm still stumped. Any further advice would be amazing.