tags:

views:

34

answers:

2

I'm trying to connect to a specific local server using mssql_connect method but not having any luck.

Any Ideas?

mssql_connect('10.12.179.66:1433\ONE_ROOF_PROD', 'username', 'password');
A: 

The "O" in ONE_ROOF_PROD is getting escaped by the blackslash (\) character. Removing the quotes around the variables might help too. Try this:

mssql_connect('10.12.179.66:1433\\ONE_ROOF_PROD', $uid, $pass);
esqew
No it's not. That's not an escape for either single or double quotes.
Matthew Flaschen
Not in single quoted strings: "To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash before a single quote, or at the end of the string , double it (\\). Note that attempting to escape any other character will print the backslash too," http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single Matthew is correct, \o is not an escape sequence in double quoted strings either.
George Marian
@George, not in double either, since O isn't an escape char for either.
Matthew Flaschen
@matthew Yah, I just looked it up. :) Thanks for clearing it up.
George Marian
Oops, sorry! :(
esqew
@seanny94 It isn't because the manual says so: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
George Marian
A: 

Let php tell you more about the cause of the error.

error_reporting(E_ALL); ini_set('display_errors', 1);

$link = mssql_connect('10.12.179.66:1433\ONE_ROOF_PROD', $uid, $pass);
if ( !$link ) {
  if ( function_exists('error_get_last') ) {
    var_dump(error_get_last());
  }
  die('connection failed');
}

In case you are using windows you might also be interested in the sqlsrv extension.

VolkerK