I've done some successful PHP things with MYSQL databases, such as creating accounts and simple threads, without any problems, but now I find myself unable to even connect to an MSSQL database.
$con = mssql_connect('correcthost','correctusername','correctpassword');
if(!$con)
{
die('Something went wrong while connecting to MSSQL');
}
mssql_select_db('correctdb', $con);That gives me the error Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server...
But, for reasons I don't come close to understanding, I can get a connection to the MSSQL database by using this method (courtesy
http://www.webcheatsheet.com/php/connect_mssql_database.php)
$myServer = "correcthost";
$myUser = "correctuser";
$myPass = "correctpassword";
$myDB = "correctdb";
$con = new COM ("ADODB.Connection")
or die("Cannot start ADO");
//define connection string, specify database driver
$conStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$con->open($conStr); //Open the connection to the database
if($con){
echo "Connected to DB<br/>";
}else{
echo "Not connected to DB<br/>";
}I'm using GoDaddy hosting, which seems to be very strange/bad in the database sense (although it could be that I'm just bad, I don't know).
Since the second method uses a connection string or something else I don't understand, I can't use my normal queries and inserts etc. with it to interact with the database.
How can I connect to the MSSQL database with the first (normal) method I mentioned?
Thank you very much.
