IIS, MS_SQL, PHP - Getting Connected
Posted: Thu Jul 05, 2007 4:22 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
As you can see, this is my Mickey-Mouse test program to connect to MSSQL server 2005 Express
I can connect using the named pipe details found under 'properties' of the named pipe,
but I cannot connect using any other connection string.
What should go after the host= ? The statements I have seen put localhost there but I have tried that and, anyway, it does not relate to my MSSQL server's name.
I seem to have tried all kinds of strings and none seem to work - except for the named pipe connection.
I have tried
MSSQL1
MSSQL$SQLEXPRESS
WEIFAN\SQLEXPRESS
WEIFAN\\SQLEXPRESS
localhost
I have run out of things to try....
I am fairly sure that I have got everything set up correctly and the correct extensions enabled in php.ini.
so... what else can I try please?
[url=http://www.perriams.co.uk/images/mssql1.gif]MS-SQL Server Management Studio Express screen[/url]Code: Select all
try {
echo "<BR>========= Connecting.... ======================";
// OK connects fine
// $dbh = new PDO('mssql:host=\\\\.\pipe\\MSSQL$SQLEXPRESS\\sql\\query;dbname=project13', ocpaul20, pword);
// This will not connect
$dbh = new PDO('mssql:host=localhost;dbname=project13', ocpaul20, pword);
echo "<BR>========= Connected Now. ======================";
} catch (PDOException $e) {
echo '<BR>Connection failed ';
print "<BR><BR>(1)Error!: " . $e->getMessage() . "<br/>";
die();
}
$dbh = null; // close connection
echo "<BR>============= CLOSED =====================";
exit;feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]