Hi all,
Been looking the net for so many times already but got tired and wanna give up.
Please enlighten me on my problem as I was trying to connect my PHP script into MSSQL 2005.
I have made and tested my script in my machine with the following platform
PHP 5
WINXP
IIS 5.1
MSSQL Express
Everything is working fine without any problem, also tested on my machine tried to connect to the production MSSQL server 2005 and it works fine as well.
Problem appeared when I tried to deploy the script on the production webserver with the following
PHP5
WIN2K3 64bit
IIS 6.0
I'm getting this error...
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft OLE DB Provider for SQL Server<br/><b>Description:</b> Login failed for user ''.' in D:\teimap\Noel\TEI_MAP_Preliminary\map\reports\pole.php:28 Stack trace: #0 D:\teimap\Noel\TEI_MAP_Preliminary\map\reports\pole.php(28): com->open('PROVIDER=SQLOLE...') #1 {main} thrown in D:\teimap\Noel\TEI_MAP_Preliminary\map\reports\pole.php on line 28
Below is my script......
<html>
<head>
<title>Pole Properties</title>
</head>
<body bgcolor="#FFFFFF" text="black">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FF6633"><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF">Pole
Information</font></strong></font></div></td>
</tr>
<tr>
<td valign="top">
<?php
include ("connect.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
?>
<table bordercolor="#000000">
<?php
$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++)
{ ?>
<tr>
<td bgcolor="#0066FF">
<?php echo $i+1 ?>
</td>
<td bgcolor="#CCFFFF">
<?php
$Fname = $rs->Fields[$i]->Name;
if ($Fname == "Pacct")
{
echo "Pole Account";
}
else
{
echo $rs->Fields[$i]->Name;
} ?>
</td>
<td bordercolor="#000000">
<?php echo $rs->Fields[$i]->Value ?>
</td>
</tr>
<?php }} ?>
</table>
<?php
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
</td>
</tr>
</table>
</body>
</html>
PHP win2k3 64bit connecting MSSQL 2005
Moderator: General Moderators
Re: PHP win2k3 64bit connecting MSSQL 2005
I don't use PHP with MSSQL, so I can't say much about your code.
However, I'd check your network libraries first, if this same code is working on other systems. If your web server and database are on the same system, make sure that the "Shared Memory" library is enabled. If they're on different systems, make sure that the "TCP/IP" library is enabled.
However, I'd check your network libraries first, if this same code is working on other systems. If your web server and database are on the same system, make sure that the "Shared Memory" library is enabled. If they're on different systems, make sure that the "TCP/IP" library is enabled.