Jump to content

Recommended Posts

Posted

don't really know if it is a PHP, IIS, or MS SQL problem

 

i have a php website trying to connect to MS SQL server from different machine.

 

Setup Before :

 

PHP website

running on IIS 5

WinXP

connecting to MS SQL Express 2005

 

ALL RUNNING ON THE SAME MACHINE WITH NO PROBLEM

 

 

Setup Now :

 

PHP website

running on IIS 6

Windows 2k3 64Bit

 

Trying Connecting to MS SQL 2005 Server on a Different Machine

 

Now I'm encountering an Error

 

"Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for SQL Server
Description: Login failed for user ''.' in "

 

 

PHP is working but anable to connect to MS SQL server... I've tried everything that I know installed SQL Client, etc...

 

Please shed some light onto my dilema as I don't find anything on web that could make things work.

 

Thank you,

 

Noel

Posted
Have you configured PHP to work with SQL?

 

I have set and configured ms sql extension on PHP... but still that error still come out.

 

btw this is the script that i'm working on...

 

include ("connection_credential.php");

if( !isset($_REQUEST['pole_hdl']) )

die("No keys");

$handle = ($_REQUEST['pole_hdl']);

 

$myDB = "poleinfo"; //Pole database

 

//create an instance of the ADO connection object

$conn = new COM ("ADODB.Connection")

or die("Cannot start ADO");

 

//define connection string, specify database driver

$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;

$conn->open($connStr); //Open the connection to the database

 

 

 

 

?>


$arrKeys = split(",", $_REQUEST['pole_hdl']); //split list of keys into array

foreach($arrKeys as $index => $handle)
{
$sql = ("SELECT PAIdt.Pacct, Type, Kind, Config, Height, Owner, DCPole, PoleAttach.Attach, Name, Pcs, JobOrder, BusData.BusID, BusData.BusDescription, BusData.NominalVoltage,BusData.SubTran, BusData.BusCategory
FROM PAIDT, PoleAttach, PoleTagging, Outside, BusInfo, BusData
WHERE handle = $handle ");

$rs = $conn->execute($sql);
$fldcnt = $rs->Fields->Count();


for ($i = 0; $i < $fldcnt ; $i++)
{ ?>





} ?>




$Fname = $rs->Fields[$i]->Name;
if ($Fname == "Pacct")
{
echo "Pole Account";
}
else
{
echo $rs->Fields[$i]->Name;
} ?>

Fields[$i]->Value ?>

<?php

$rs->Close();

$conn->Close();

$rs = null;

$conn = null;

?>

Posted

Hello

 

One way I use to test SQL Server logins is to take all the other stuff out of the situation, and you can do that by using SQL Server itself, or more accurately a second one.

 

So, sitting at your SQL Server Express box, you could use a command line to attempt to login to the target SQL instance. This tells you if it's accepting logins or not.

 

e.g.

 

(and by the way this is from memory, as I'm not in front of a capable machine right now!)

 

SQLCMD -S [servername] -U [username -P [password] -d [databasename]

 

note that [servername] must include the instance, so if your database is running on an instance called FRED on DB01, you'd specify DB01\FRED

 

If you get a nice shiny 1> prompt then all is well and the problem is somewhere else. If it's a login failed message then it could relate to the account itself, SQL Server not accepting remote logins, firewalls etc.

Posted

Since my SQL server Express box is working with itself, i tried using it and pointing the sql server onto the SQL server 2005 where i log in and pulled the data resulted the script is working perfectly.

 

 

what i find strange here is why my script can't run on my second machine which has

 

Win2003 Server 64bit

IIS 6

PHP

 

why it can't access the MS SQL 2005 server, maybe I'm missing something on my configuration or some where?

 

 

Hello

 

One way I use to test SQL Server logins is to take all the other stuff out of the situation, and you can do that by using SQL Server itself, or more accurately a second one.

 

So, sitting at your SQL Server Express box, you could use a command line to attempt to login to the target SQL instance. This tells you if it's accepting logins or not.

 

e.g.

 

(and by the way this is from memory, as I'm not in front of a capable machine right now!)

 

SQLCMD -S [servername] -U [username -P [password] -d [databasename]

 

note that [servername] must include the instance, so if your database is running on an instance called FRED on DB01, you'd specify DB01\FRED

 

If you get a nice shiny 1> prompt then all is well and the problem is somewhere else. If it's a login failed message then it could relate to the account itself, SQL Server not accepting remote logins, firewalls etc.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...