473,462 Members | 1,055 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Mssql Iis6

11
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','password ') or die("Connection failed");

echo '<p>line 2</p>';

mssql_select_db('DATABASENAME', $con);
$sql = 'SELECT * FROM sys.tables';
if ($res = mssql_query($sql, $con)) {
print(mssql_num_rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($con);

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
Jul 28 '07 #1
14 2897
kovik
1,044 Expert 1GB
It sounds to me as though you have error_reporting turned off if your script fails at mssql_connect(), but doesn't tell you. You need to turn error_reporting on.

The problem is likely that the mssql extension is not loaded in your php.ini. Look in your php.ini and find this line:

extension=php_mssql.dll

Does it have a semicolon ahead of it? If so, remove the semicolon, save the file, and restart your server.
Jul 28 '07 #2
guswebb
11
ok. so now i'm making a little progress. i have turned on error reporting and now have the following error:

Parse error: syntax error, unexpected T_STRING in C:\filepath on line 10

my entire code is as follows:

<?php
echo "<p>line 1</p>";

error_reporting(E_ALL);
ini_set('display_errors', True);

$con = mssql_connect("MSSQLINSTANCE","administrator","pas sword") or die("Connection failed");
mssql_connect()

mssql_select_db("DBNAME");
$sql = "SELECT * FROM TABLENAME";
if ($res = mssql_query($sql, $con)) {
print(mssql_num_rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($con);

echo "<p>line 2</p>";

?>


i removed one of the echo lines that i referred to earlier so there are now only 2, so that i can see when they are written, if at all. currently, using the exact code as above, neither of them are written, nor is anything other than the error message as shown above.

this error message appears to relate to the code that defines that DB name but i can't see what is wrong with this.

any ideas? (and apologies in advance for not grasping what i'm doing wrong!)
Jul 28 '07 #3
mwasif
802 Expert 512MB
guswebb, kinldy use proper PHP code tags for your source code instead of bold. It will help others to understand your code.
Jul 28 '07 #4
mwasif
802 Expert 512MB
On line 8, you have mssql_connect() without semicolon but still there is no need for 2nd mssql_connect(). Remove this line.
[PHP]<?php
echo "<p>line 1</p>";

error_reporting(E_ALL);
ini_set('display_errors', True);

$con = mssql_connect("MSSQLINSTANCE","administrator","pas sword") or die("Connection failed");
mssql_connect()

mssql_select_db("DBNAME");
$sql = "SELECT * FROM TABLENAME";
if ($res = mssql_query($sql, $con)) {
print(mssql_num_rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($con);

echo "<p>line 2</p>";

?>[/PHP]
Jul 28 '07 #5
guswebb
11
On line 8, you have mssql_connect() without semicolon but still there is no need for 2nd mssql_connect(). Remove this line.
[PHP]<?php
echo "<p>line 1</p>";

error_reporting(E_ALL);
ini_set('display_errors', True);

$con = mssql_connect("MSSQLINSTANCE","administrator","pas sword") or die("Connection failed");
mssql_connect()

mssql_select_db("DBNAME");
$sql = "SELECT * FROM TABLENAME";
if ($res = mssql_query($sql, $con)) {
print(mssql_num_rows($res) . " tables in database.\n");
} else {
print("SQL failed.\n");
}
mssql_close($con);

echo "<p>line 2</p>";

?>[/PHP]
i have removed the line 8 code and also checked the extension=php_mssql.dll entry in the php.ini file as per your PM. i changed this ini file before rebooting, but now it appeared again with a semicolon in front of the line where I had previously removed it. not sure how, maybe i didn't save it when i thought i had.

is the php.ini file only meant to be stored in the windows/system32 folder and not in the C:\PHP install folder?
Jul 28 '07 #6
mwasif
802 Expert 512MB
You can know the location of php.ini in phpinfo output.
[PHP]<?
phpinfo();
?>[/PHP]
Jul 28 '07 #7
guswebb
11
and i still have the problem whereby my phpinfo.php file does not load anything other than a blank page, with no errors.

is there something more fundamental wrong with my installation/configuration that i need to get sorted before attempting to troubleshoot the MSSQL connection issue?

my phpinfo.php file reads...

[PHP]<? phpinfo() ?> [/PHP]

this renders a blank page, but from what i've read elsewhere, it should load a summary of my system's settings. is this correct?
Jul 28 '07 #8
guswebb
11
You can know the location of php.ini in phpinfo output.
[PHP]<?
phpinfo();
?>[/PHP]

i have resaved the phpinfo.php file containing code exactly as you have typed it and still i get a blank page.
Jul 28 '07 #9
mwasif
802 Expert 512MB
from what i've read elsewhere, it should load a summary of my system's settings. is this correct?
It should load a summary.

Have you turned on error reporting? Try this code instead
[PHP]<?php
error_reporting(E_ALL);
phpinfo();
?>[/PHP]
Jul 28 '07 #10
guswebb
11
ok. now i'm getting somewhere. i can see the phpinfo output. this shows my php.ini file to be in the C:\Windows directory and not the system32 sub-directory. i have overwritten both versions with one that contains the extension=php_mssql.dll as loaded.

i am still getting the error in line 7 as above.
Jul 28 '07 #11
mwasif
802 Expert 512MB
Did you set the correct value for extension_dir in php.ini? extension_dir will have the path where php_mssql.dll is located in your PHP directory.
Jul 28 '07 #12
guswebb
11
i did, but foolishly, and in my haste, i added this as an extra line of code near the top of the page, leaving the original line of code lower down. this meant that my custom value was being overwritten by the default.

so...i have corrected that problem and now have a more meaningful error relating to the MSSQL connection, as follows:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: MSSQLINSTANCE in C:\filepath on line 7
Connection failed


is it to do with the way in which the MSSQL instance is defined? i have seen threads that refer to this being in the format of

\\.\pipe\MSSQL$instance\sql\query
Jul 28 '07 #13
mwasif
802 Expert 512MB
Did you read the user comments on http://www.php.net/manual/en/function.mssql-connect.php expecially this one?
Jul 28 '07 #14
guswebb
11
Did you read the user comments on http://www.php.net/manual/en/function.mssql-connect.php expecially this one?
i did, but having gone back through them, and following the installation of MDAC 2.8, my connection now works!

i have had to use the notation of ,1433 to stipulate the port on the MSSQL server.

thanks for all your help.
Jul 28 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that...
1
by: JackTorrance | last post by:
Hi i have a problem with IIS6 and MSSQL and i hope that someone can help me. this is the configuration: Windows 2003 IIS6 MSSQL 7.0 Standard Edition ADO 2.5
3
by: gharmel | last post by:
I'm trying to get some clues on why I get (much) slower responses from my PHP applications when dealing with a remote sql server as opposed to a local sql server. Here's my situation: Server...
16
by: davemateer | last post by:
Hi We have a current system: Linux / Apache / PHP4.x talking to Microsoft SQL 2000 Thinking about going to: Windows 2003 / PHP4.x talking to the same Microsoft SQL 2000 box...
8
by: eugenio | last post by:
Hi...not sure if this is the right group for this posting, but i'm don't know where else to post. I've got a simple problem...I have a linux box running apache 2.0 and php5. I'm trying to use the...
2
by: vrba | last post by:
Hi, I need one web site in UTF8 with MSSQL2005 (customer request) Configuration: IIS6+PHP5/Win2003 (Czech locales)--> MSSQL/Win2003 Database returns data in CP1250, rest is correct in UTF8....
2
by: Andrew Wan | last post by:
Okay, this is really weird. We have two Windows 2003 Server SP1 PCs. One hosts IIS6 website, and the other hosts our DCOM service program. Our website is ASP/XSL. An ASP page uses...
6
Ryan F Bracy
by: Ryan F Bracy | last post by:
I'm currently a computer networking student, and a semester long project this year requires us to build an online store using IIS6 and MSSQL. I have run into a dead end in this project and cannot...
1
by: lilOlMe | last post by:
Can you install IIS6 on a system other than Windows Server 2003? I'd like to install IIS6 on Windows XP. I've been trying to find out the system requirements for IIS6 but I haven't found a clear...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.