Page 1 of 1
PHP Connecting to mssql
Posted: Mon Jun 30, 2008 8:45 am
by hairytea
Hi,
I have been unsuccessful at trying to gain access to a remote mssql server (not mysql).....quick question....
Does the remote mssql server need to have php installed or is it just the webserver that is trying to connect to the mssql server that needs php supported?
I have tried script after script from all over the place including php.net codes. I have all the parimeters needed i.e. username password ip address etc and the following code is what i am trying to use at present....
Code: Select all
<?php
$myServer = "IP-REMOVED";
$myUser = "USERNAME-REMOVED";
$myPass = "PASSWORD - REMOVED";
$myDB = "DATABASENAME - REMOVED";
// 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 . ".";
// close the connection
mssql_close($dbhandle);
?>
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:06 am
by highjo
is your codes given an error or something?What's the deal?
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:08 am
by hairytea
Thank you for the speedy response...
I just get my error printed to the screen....
Couldn't connect to SQL Server on IP-REMOVED
Many thanks
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:10 am
by hairytea
I need to clarify whether the sql server needs to have php installed or not?
This maybe my problem????
FYI: The webserver has php support but i dont have access to the sql server i am trying to connect to and i really do not know whether that has php installed nor whether it neds php installed?
Is it just the web server that neds php installed?
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:26 am
by highjo
don't think mssql care about where the client is calling from.it cares whether the client has the drivers(as far as i'm concerned).can you check first if you can connect with mssql client?if it works then we would now worry about the version of php you are using, because i'll suggest to use PDO or PEAR DB package.
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:32 am
by hairytea
highjo wrote:don't think mssql care about where the client is calling from.it cares whether the client has the drivers(as far as i'm concerned).can you check first if you can connect with mssql client?if it works then we would now worry about the version of php you are using, because i'll suggest to use PDO or PEAR DB package.
Thank you but could you please clarify...
Do you mean the web server needs to have mssql drivers as well as the remote server i am trying to connect to?
Not sure what PDO or PEAR package is? Could you elaborate?
How do i connect with a mssql client? What is mssql client?
Do you mean a machine on the same network as the server? if yes i am remoting in and the server and it's local clients on network are not accesible for me!
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 9:49 am
by highjo
before we go further can you describe your system configuration?i mean by that if you have iis and php as module + mssql or using apache +php
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 10:00 am
by hairytea
highjo wrote:before we go further can you describe your system configuration?i mean by that if you have iis and php as module + mssql or using apache +php
The web server that scripts are uploaded to supports php5 does NOT have mysql or mssql.
(The remote server i am trying to connect to from the web server is the sql server)
From running phpinfo.php i see the server is running iis6 (
http://www.icaltd.co.uk/phpinfo.php)
Is this what you needed?
Re: PHP Connecting to mssql
Posted: Mon Jun 30, 2008 10:45 am
by highjo
yeah i can see that it's from a hosting company.that means we have limited options.what i meant by mssql client is your microsoft sql server (like 2000 or 2005) installed on your machine where you develop.With that you can try to connect to your remote sql database by creating new connection and enter your credentials.see whether the connection is ok.
then i'm afraid your have to write to your hosting administrator or support service.explain the problem and ask them if the have enabled TCP/IP and Named Pipes Protocol in MS SQL Server.if you want to know about all this check this
http://www.php.net/function.mssql-connect and
http://www.daniweb.com/forums/thread22564.html