Hi. I'm a newbie to PHP and am having a few problems as follows...
I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to MSSQL 2k (SP4) on server 2 (using ASP).
I can load a basic 'Hellow world' PHP page hosted on server1 but when I add the code to create a simple connection to MSSQL on server 2, my PHP doesn't seem to connect nor output any of the desired query results to screen (e.g. number of rows in a table). I have placed 3 echo statements in amongst this page in order to see what is being processed successfuly as I have no other information as to where the failure may lie. Where can I find PHP error logs?
echo1, which appears at the start of the php script, writes to the screen fine.
echo2, which appears immediately after the MSSQL connection variable definition, does not write to the screen.
echo2, which appears after the MSSQL query results are to be written to the screen, does not write to the screen (nor do the query results).
The PHP script I am using is as follows:
<?php
echo '<p>line 1</p>';
$con = mssql_connect(' MSSQLINSTANCE', 'username','pas sword') or die("Connection failed");
echo '<p>line 2</p>';
mssql_select_db ('DATABASENAME' , $con);
$sql = 'SELECT * FROM sys.tables';
if ($res = mssql_query($sq l, $con)) {
print(mssql_num _rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($co n);
echo '<p>line 3</p>';
?>
Obviously, the values in CAPS above are replaced with the appropriate values for the MSSQL instance on server 2, administrator username, administrator password, and db name.
I have followed all the manuals, discussion boards and instructions I can find on the net and still no joy. I have named pipes and TCP/IP enabled on the MSSQL server. I have also addressed the issue of the ntwdblib.dll file version, by copying from the SQLserver across to the PHP directory and system32 directory on server1.
In addition to the problem above, and tracking back as far as I can, I am unable to get the file phpinfo.php to load on server1. I guess that I first of all need to solve this problem before tackling the MSSQL connection issue.
The phpinfo.php file reads a follows:
<?
phpinfo();
?>
All advice appreciated. Thanks in advance
I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to MSSQL 2k (SP4) on server 2 (using ASP).
I can load a basic 'Hellow world' PHP page hosted on server1 but when I add the code to create a simple connection to MSSQL on server 2, my PHP doesn't seem to connect nor output any of the desired query results to screen (e.g. number of rows in a table). I have placed 3 echo statements in amongst this page in order to see what is being processed successfuly as I have no other information as to where the failure may lie. Where can I find PHP error logs?
echo1, which appears at the start of the php script, writes to the screen fine.
echo2, which appears immediately after the MSSQL connection variable definition, does not write to the screen.
echo2, which appears after the MSSQL query results are to be written to the screen, does not write to the screen (nor do the query results).
The PHP script I am using is as follows:
<?php
echo '<p>line 1</p>';
$con = mssql_connect(' MSSQLINSTANCE', 'username','pas sword') or die("Connection failed");
echo '<p>line 2</p>';
mssql_select_db ('DATABASENAME' , $con);
$sql = 'SELECT * FROM sys.tables';
if ($res = mssql_query($sq l, $con)) {
print(mssql_num _rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($co n);
echo '<p>line 3</p>';
?>
Obviously, the values in CAPS above are replaced with the appropriate values for the MSSQL instance on server 2, administrator username, administrator password, and db name.
I have followed all the manuals, discussion boards and instructions I can find on the net and still no joy. I have named pipes and TCP/IP enabled on the MSSQL server. I have also addressed the issue of the ntwdblib.dll file version, by copying from the SQLserver across to the PHP directory and system32 directory on server1.
In addition to the problem above, and tracking back as far as I can, I am unable to get the file phpinfo.php to load on server1. I guess that I first of all need to solve this problem before tackling the MSSQL connection issue.
The phpinfo.php file reads a follows:
<?
phpinfo();
?>
All advice appreciated. Thanks in advance
Comment