January 24, 2006 at 6:00 am
Hi all,
I'm new to SQL Server so I appreciate any help.
I am using PHP as my server side language.
Can anyone tell me if this is correct? Especially the error part.
@ $db = mssql_pconnect('localhost', 'training', 'training2');
if (!$db)
{
echo '
Could not connect to database
';
exit;
}
// Select Database
mssql_select_db('training_dub') or die(mssql_error());
?>
January 25, 2006 at 7:00 am
Have you run this code? If so, what error did you receive? The error will at least give us a general idea of what to look at. At first glance this looks correct, but I have only connected to a mySQL database with PHP.
try using the IP Address or name of the server rather than localhost. I would also change the pconnect to utilize or die so you can see the error.
January 25, 2006 at 8:31 am
I had to setup my database calls as ODBC to make it work.. it works just fine that way.
January 25, 2006 at 10:46 am
I use the following in one of my scripts to connect to SQL Server...
$host = 'dbserver';
$user = 'myuser';
$password = 'secretpassword';
$link1 = mssql_connect($host,$user,$password) or DIE("DATABASE FAILED TO RESPOND.");
mssql_select_db("db",$link1);
Hope this helps!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply