Jump to content

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
https://forums.phpfreaks.com/topic/42759-solved-ms-sql-2000-wphp5-using-ole/
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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.