mssql_connect pulling my hair out....please please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

mssql_connect pulling my hair out....please please help

Post by hairytea »

I want to get a connection to a remote host....

I have been supplied...

Server IP Address
username
password
port number
database name

from looking throught the php.net i am more confused lol...a lot of posts mention the php_dblib.dll or php_mssql.dll files missing?

What does this mean? does it mean i need to contact the webhost where the script is running from and tell them to add these file to the php.ini?

Anyway, my script is as follows...

Code: Select all

 
<?php
$myServer = "xx.xxx.xx.xxx:1433";
$myUser = "xxx";
$myPass = "xxxx";
$myDB = "xxxxxx";
 
// 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);
?>
 



ANY IDEAS?
madan koshti
Forum Commoner
Posts: 50
Joined: Fri Jun 06, 2008 4:25 am

Re: mssql_connect pulling my hair out....please please help

Post by madan koshti »

you need to make sure that extension=php_mssql is insalled on your php system.By default "extension=php_mssql.dll" is kept off.you need to uncomment that lineinphp.ini.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: mssql_connect pulling my hair out....please please help

Post by onion2k »

What's the problem? What error message are you getting?
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: mssql_connect pulling my hair out....please please help

Post by hairytea »

madan koshti wrote:you need to make sure that extension=php_mssql is insalled on your php system.By default "extension=php_mssql.dll" is kept off.you need to uncomment that lineinphp.ini.

Hi,

would i need to change my system parameters even though I am trying to connect fromt the website and not from my local system?

Many thanks

Andrew
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: mssql_connect pulling my hair out....please please help

Post by hairytea »

onion2k wrote:What's the problem? What error message are you getting?
I am getting the following....

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: xx.xxx.xx.xxx:1433 in e:\domains\i\XXXXXX\user\htdocs\mysqlConnection.php on line 15
Couldn't connect to SQL Server on xx.xxx.xx.xxx:1433
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: mssql_connect pulling my hair out....please please help

Post by onion2k »

The code is working fine then, the problem is either that your server is configured to block outgoing connections, or the Mssql server is configured to block incoming connections. Neither of which can be fixed by talking about it here. You'll have to talk to whoever controls the servers/networks you're using.
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: mssql_connect pulling my hair out....please please help

Post by hairytea »

onion2k wrote:The code is working fine then, the problem is either that your server is configured to block outgoing connections, or the Mssql server is configured to block incoming connections. Neither of which can be fixed by talking about it here. You'll have to talk to whoever controls the servers/networks you're using.
I'm glad you said that... have over 25 emails (from today only) to the IT guys responsible for this server and they keep repeating the same....

IT - This is a Microsoft Server NOT a MySql server and your code is incorrect for making connection you need to write VB script???

ME - I'm sure the server is just rejecting traffic from the website, please investigate.

IT - No, it's not the problem.


SEE WHY I'M PULLING MY HAIR OUT????


AAAAAAAAAAAARRRRRGGGGGGHHHHHHHHHH :banghead: :banghead: :banghead:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: mssql_connect pulling my hair out....please please help

Post by onion2k »

Well, you have called your script "mysqlConnection.php", so I can kind of see their point... The error message shows you're using the right function for mssql though.

Ask them if they can tell you what the VBscript for a remote connection should be. If you can get that working, by opening up whatever links/ports need to be open on the network, then PHP should work too.
Post Reply