I’ve never really used MS server or anything like that before, i have, however used Linux servers before and know what i am doing there.
I have to use a Windows server with MS SQL now, but i haven’t a clue how to connect to it with PHP, usually it would be a matter of:
$data = mysql_connect();
But this didn’t work, so i done a bit of research and found this little number:
$data = mssql_connect();
This is used for MS SQL database server, well from what i can’t see. Anyway the problem is, when i use the first, the ‘or die’ method kicks in saying that i cannot connect to the database as you would expect. But when i use the second function, nothing happens, as if i have a syntax error.
Any ideas? Any help getting started with MS SQL Server?
Thanks for the time
Brian.
P.S Heres my code just incase i’m being silly and have done something wrong…..
$remotedb_host = "";//Here is the server IP address
$remotedb_username = "user1";
$remotedb_pass = "example";
//$remotedb_name = "exampletable";
// Run the connection here
$dbhandle = mssql_connect($remotedb_host, $remotedb_username, $remotedb_pass)
or die("Couldn't connect to SQL Server ");
echo $dbhandle;
echo "hello";//this is to test if anything is displayed at all on the page
Also i will be remote connecting from a linux server, is this a bad thing to do? should i keep it all on the Windows Server? Does it make a difference in all fairness?
Thanks Again.
First of all, about your errors, i recommend adding on top
This will show you all errors that occur.
Make sure you have the mssql extension on in your php.ini file (remove the # sign before mssql.so or the ; sign from the mssql.dll)
Also, try
var_dump()ing the $dbhandle instead of echoing it.You could also verify the connection by using the following as stated in the PHP Manual :
Shai