Jump to content

[SOLVED] MS SQL 2000 w/PHP5 using OLE


davidc3084

Recommended Posts

Environment -

 

Windows XP Professional Client running Apache 2.x w/ PHP5.  Accessing a Remote SQL Server 2000 DB.

Can Access SQL Server DB w/ standard SQL Server Query Analyzer Tool.

php.ini has the following extensions (in which all dll have been copied to PHP root) php_pdo_mssql.dll, php_msql.dll, php_mssql.dll.

 

Attempting to access w/ COM approach.  Tried mssql_connect, mssql_pconnect both w/ DSN, TCPIP and Name Piples.  Cannot seem to make connection.  Below is a snippet of the code.  I think it is a networking, infrastructure issue, but cannot debug.

 

 

Q:  Is there anyway to track - how and why the connection is failing?  At this point I just know it errors out.  So its really tough to debug.

 

 

<html>

<head>

  <title>PHP Test</title>

</head>

<body>

<h1> SQL/PHP /<h1>

 

<?php

 

$HOST = "CSCS02";

$USER = "sa";

$PASS = "mypswd";

$DB = "MY_DB_A";

 

$dsn = "Provider=SQLOLEDB;Data Source=$HOST;UserId=$USER;Password=$PASS;Initial Catalog=$DB";

 

$charPage = CP_UTF8;

 

$db = new COM("ADODB.Connection", NULL, $charPage);

$db->Open($dsn);

 

echo "made it";

 

?>

</body>

</html>

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Use SQL Server Configuration Manager to check if it is configured to handle any TCP/IP, VIA and Named Pipes traffic. I belive that it will not handle any trafic default afther installlation. You will find the util under Configuration Tools under your sqlserver folder.

Link to comment
Share on other sites

Problem solved.  Lack of SQL Server experience on my part - more an Oracle person.  Evidently the user SA is a special type of user account that has access to catalogues (i.e. i could connect to Query Analyzer), but is not considered a valid db user.  Create a user in my targeted DB and all worked.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.