PHP Pages That Contain SQL Script Displays a Blank White Screen

Issue:
PHP pages display just fine under IIS 8.5, Windows 2012 R2, PHP ver. 5.3, that do not contain SQL connection scripts, however, the few pages that have SQL connection scripts do not display.

I was able to test that PHP was installed correctly using the phpinfo.php script, but I’m getting no error messages when I view the PHP pages that contain SQL connection scripts. (i.e. the page pulls data from a SQL database.)

The PHP.ini file shows the .DLLs associated with the version of PHP installed.

Question:
What is preventing the PHP pages that pull from SQL database from displaying?
What else do I need to check/install/modify to make it work?

I appreciate your feedback and assistance

Thanks!

Steve

Put this on the top of the php page

error_reporting(E_ALL);
ini_set(“display_errors”, 1);

Hopefully - It will show the error that might be happening.

The white screen of death is usually a fatal error somewhere. Check ypur logs or enable debug output to hopefully get an error message instead of the white page.

I’ve added the code snippet …
error_reporting(E_ALL); ini_set("display_errors", 1);

but still nothing displayed on the page.

<?php 

	include("../includes/db_connect_intranet.php");
	
	session_start();
		
	include("../includes/facility.php");
	
	//post and get variables on form submit or sort or first load
	if (!empty($_POST['comp_no'])) {
		$comp_no = strtoupper($_POST['comp_no']);
	} else if (!empty($_GET['comp_no'])) {
		$comp_no = strtoupper($_GET['comp_no']);
	} else {
		$comp_no = "%";
	}
	
	// set sort orders
	// first load
	if (empty($_GET['order'])) {
		$order = "LOC_ZONE";
		$_SESSION['bm_order'] = $order;
		$_SESSION['bm_sort'] = "ASC";
	}
	// header for sorting was clicked
	else {
		$order = $_GET['order'];
		
		if ($order != $_SESSION['bm_order']) {
			$_SESSION['bm_sort'] = "ASC";
		}
		else if ($_SESSION['bm_sort'] == "DESC") {
			$_SESSION['bm_sort'] = "ASC";
		}
		else {
			$_SESSION['bm_sort'] = "DESC";
		}
		$_SESSION['bm_order'] = $order;
	}
?>

Is there something in the PHP code that’s not right? The PHP page was written in an earlier version of PHP, and works fine on an serer with PHP 3…is there a certain syntax required for connecting to SQL and pulling data in PHP 5.3?

I also checked the log files and it didn’t show any information that would indicate there was a fatal error

So bizarre…so close and yet so far.

Your feedback and assistance is greatly appreciated.

Thanks!

I would comment out

[php] include("…/includes/db_connect_intranet.php");
include("…/includes/facility.php");[/php]

Then add

[php]echo ‘this is a test’;[/php]

To make sure it’s one of the includes that’s not causing the issue.

Also what logs did you check in IIS?

IF you click on your server in IIS, then click on PHP Manger, then under php Settings it will show you where the php logs are located.

Getting better results this time thanks to your suggestion…I commented out the ‘includes’ statements and added the ‘this is a test’ script…and this is what was returned when I refreshed the web page…

this is a test
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\inetpub\wwwroot\intranet\operating_reports\bom_search.php:6) in C:\inetpub\wwwroot\intranet\operating_reports\bm_search.php on line 9

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\wwwroot\intranet\operating_reports\bom_search.php:6) in C:\inetpub\wwwroot\intranet\operating_reports\bm_search.php on line 9

Line 9: reads as follows:

session_start();

The ‘sessiondata’ folder exists under C:\Inetpub\Intranet\sessiondata…

the PHP.ini file shows the session.save_path as: session.save_path = “C:\Inetpub\Intranet\sessiondata”

Should the session save path be something different?

Thanks!

move the session_start(); to the top of the file…

Hope this helps…

The web pages exist on the web server and the bm_search.php web page exists in a sub-directory, ‘\intranet\operating_reports’ …the PHP.ini exists in: c:\program files (x86)\PHP.

trying to make sense of it myself…

That seemed to resolve the issue with the headers…but now the error message reads:

Fatal error: Call to undefined function mssql_init() in C:\inetpub\wwwroot\intranet\operating_reports\bm_search.php on line 142

<?PHP
						if ($comp_no != "%") {
						//execute stored procedure
			Line 142 -->	$val_query = mssql_init("pp_BMSearch", $s2);
						mssql_bind($val_query, "@facility", &$facility, SQLVARCHAR); 
						mssql_bind($val_query, "@component", &$comp_no, SQLVARCHAR); 
						mssql_bind($val_query, "@order", &$order, SQLVARCHAR);
						mssql_bind($val_query, "@sort", &$_SESSION['bm_sort'], SQLVARCHAR);
						$sql_result = mssql_execute($val_query);
						$row_num = mssql_num_rows($sql_result);	
						$row = mssql_fetch_array($sql_result)

I checked the PHP.ini file to see if the reference to ‘mssql.dll’ is not commented out.
extension=php_mssql.dll

Not sure if that has anything to do with the error, but it was a hunch.

Here’s your answer…

http://php.net/manual/en/intro.mssql.php

MSSQL doesn’t work with php 5.3 you need to switch everything over to the driver from microsoft…

Then you have to change a lot of your code from mssql_ to sqlsrv_

Or you can just install php 5.2 and run this application off php 5.2 and run other applications off 5.3 - Which you can do in IIS.

Not the news you want to hear, but at least this defines the path you need to take if you want to get it running.

[member=69011]Topcoder[/member] Could you run this using PDO (it supports mssql)?

[member=71845]JimL[/member] I don’t know, he would have to test it.

Is there something that will help guide me through converting the SQL mssql to sqlsvr?

I’m not as versed in PHP as some others, but I’m open to learning and strengthening my coding skills/knowledge.

Thanks!

(although it would be easier to install PHP 5.2, I’d like to try plan A first before giving in to plan B.)

I never used either, so i wont be of much help. Just do a google search and try to find out what the difference in syntax is. It might be as easy as one search and replace in your codebase.

Okay…I’ll search online for some syntax examples and give it a go…I appreciate your help and information.

Thanks! I’ll reply back with an update in a few days.

Update…the pages work (except one)…I can now view the web pages, but one page in particular is displaying a fatal error message after changing from mssql to sqlsrv…

Message: Fatal error: Class ‘COM’ not found in C:\inetpub\wwwroot\intranet\search_results.php on line 104

<?php // Here's where the action takes place, using Microsoft Indexing Service (IXSSO) // running on the webserver with a catalog pointed to a file server (these specified // in search_params), this code creates a query and searches in the correct locations Line 104:..............$Q = new COM("ixsso.Query"); $util = new COM("ixsso.util"); $Q->Catalog = $catalog; $Q->DefineColumn("Status = d5cdd505-2e9c-101b-9397-08002b2cf9ae status"); $Q->DefineColumn("Name = d5cdd505-2e9c-101b-9397-08002b2cf9ae name"); $Q->DefineColumn("Date = d5cdd505-2e9c-101b-9397-08002b2cf9ae date");

Does sqlsrv and 5.3 function well with ‘ixsso.Query’ or do I need to make some more changes?

Your feedback is much appreciated.

Thanks!

Add This to your PHP.INI

[php][COM_DOT_NET]
extension=php_com_dotnet.dl
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service