I use PHP 5.2 and it usually mssql_connectworks fine, but I try to connect to the new MS SQL server and it will not connect. I probably have something wrong with the connection details or credentials, but I can’t say because I can’t get the error message.
The method mssql_connect()returns false, and the connection is not available.
mssql_get_last_message() returns nothing - so how can I explain why my connection failed?
Does anyone have any ideas?
In MySQL, I would use mysql_error- but there seems to be no equivalent for ms_sql.
[EDIT]
This question is not a duplicate of " MSSQL_CONNECT returns nothing - there is no error, but no answer " - I use php 5.2, and the code works fine for other connection details. I need to figure out how to output what a connection error is, and not a connection problem.
[EDIT2]
To clarify:
- the extension is enabled on the server
- The code works great for existing connection information.
- I am using new connection details and don’t know if the hostname or password is wrong
- I know that the code does not connect, because I check if it is connected
- I want to find out the connection error - as you can with MySQL.
Sample code below:
$db_connection = mssql_connect($host, $user, $pass);
$db = mssql_select_db($dbname, $db_connection);
if (!$db_connection) {
echo "No connection";
echo "connection failed because: " . ???????;
die;
}
What should I put instead ???????to get a connection error message?