php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11202 php.exe Application error
Submitted: 2001-05-30 15:26 UTC Modified: 2001-06-21 11:25 UTC
From: jeremy at deadbeef dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.5 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-05-30 15:26 UTC] jeremy at deadbeef dot com
php.exe - Application Error
The instruction at "0x00c4dff2" referenced memory at "0x00c4dff2". The memory could not be "read".

This is happening intermitantly for many of my pages.  Sometimes hitting refresh will fix the problem, sometimes it will cause another error.

I am running php 4.0.5 as a cgi under IIS 5 on Win2000.

My script uses ODBC to connect to an access database.
It also uses header() to force the user to authenticate.

Here is the script:
<?php
	require_once('auth.inc');
?>
<html>
<head>
<title>Enter a new listing</title>
</head>
<body onLoad="document.all.year.focus();">
<?php 
	if (@$do_save) {
?>
	Cannot yet save listings.
<?php } ?>
<script language="JScript">
<?php 
	$allmodels = $dbh->getAll("select make, model, model_description from models");
	echo "var allmodels = new Array(new Array(0,0,0)";
	foreach ($allmodels as $row) {
		echo ",\n	new Array(", $row[0], ",", $row[1], ", '", $row[2], "'";
		echo ")";
	}
	echo ");\n";
?>
function makechanged() {
	var value = document.all.make.value;
	var modelopts = document.all.model.options;
	while (modelopts.length > 0)
		modelopts.remove(0);
	if (value == -1) {
		var popup = open("newmake.php", null, "height=100,width=300,status=yes,toolbar=no,menubar=no,location=no");
	} else if (value != 0) {
		var obj = document.createElement("OPTION");
		var i;
		modelopts.add(obj);
		obj.value=null;
		obj.innerText="";
		
		for(i=0;i<allmodels.length;i++) {
			if (value != allmodels[i][0])
				continue;
			obj = document.createElement("OPTION");
			modelopts.add(obj);
			obj.value=allmodels[i][1];
			obj.innerText=allmodels[i][2];
		}
		obj = document.createElement("OPTION");
		modelopts.add(obj);
		obj.value=-1;
		obj.innerText="Other...";
	}
}
function addnewmake(ident, desc) {
	var sel = document.all.make;
	var opts = sel.options;
	var i;
	var didit=0;
	for(i=0;i<opts.length;i++) {
		if (ident == opts[i].value) {
			opts[i].innerText=desc; 
			opts[i].selected=true;
			didit=1;
			break;
		}
	}
	if (!didit) {
		var obj = document.createElement("OPTION");
		opts.add(obj);
		obj.value=ident;
		obj.innerText=desc;
		obj.selected=true;
	}
	makechanged();
}
function modelchanged() {
	var makevalue = document.all.make.value;
	var makedesc = document.all.make.options[document.all.make.selectedIndex].innerText;
	var value = document.all.model.value;
	if (value == -1) {
		var popup = open("newmodel.php?make_id=" + makevalue + "&make_desc=" + makedesc , null, "height=100,width=300,status=yes,toolbar=no,menubar=no,location=no");
	}
}
function addnewmodel(make, ident, desc) {
	var i;
	var foundit = 0;
	alert("3");
	alert("addnewmodel " + make + " " + ident + " " + desc);
	for(i=0;i<allmodels.length;i++) {
		if (make == allmodels[i][0] && ident == allmodels[i][1]) {
			foundit = 1;
			allmodels[i][2] = desc;
			break;
		}
	}
	alert("4");
	if (!foundit) {
		i = allmodels.length;
		allmodels[i] = new Array();
		allmodels[i][0] = make;
		allmodels[i][1] = ident;
		allmodels[i][2] = desc;
	}
	alert("5");
	makechanged();
	alert("6");
	var sel = document.all.model;
	var opts = sel.options;
	for(i=0;i<opts.length;i++) {
		if (ident == opts[i].value) {
			opts[i].selected=true;
			break;
		}
	}
	alert("7");
}
</script>

<h1>New Listing</h1>
<form action="listing.php" method=post>
<hidden name=do_save value=1>
<table border=0>
<tr>
<th>Year</th>
<td><input type=text name=year size=4 id=year></td>
</tr>
<th>Make</th>
<td><?php 
	$allmakes = $dbh->getAssoc("select make, make_desc from makes");
	echo "<select name=make id=make onchange=\"makechanged();\">\n";
	echo "<option selected></option>\n";
	foreach ($allmakes as $makeid => $makedesc) {
		echo "<option value=$makeid>$makedesc</option>\n";
	}
	echo "<option value=-1>Other...</option>\n";
	echo "</select>\n";
?>
</td></tr>
<th>Model</th>
<td><select name=model onChange="modelchanged();">
</select>
</td></tr>
</table>

</form>

</body>
</html>


auth.inc
---------
<?php
    //**************************************
    // for :HTTP authentication with PHP on IIS
    //**************************************
    // Source: http://brecht.sanders.org/
    //**************************************
    // Name: HTTP authentication with PHP on IIS
    // Description:A simple way to provide Basic Authentication using PHP on Internet Information Server 4 or 5. IMPORTANT: Read the "assumes" section below before using. Tested on Windows 2000 with IIS 5 and PHP 4.0.2. Also, make sure you turn off ALL IIS authentication options, including the default "Integrated Windows Authentication". Leave only Anonymous Access checked, or this will not work.
    // By: Dan Hendricks
    //
    //
    // Inputs:None
    //
    // Returns:None
    //
    //Assumes:This code will NOT work if you have not the PHP installation instructions in the README.TXT file, entitled "Installation Notes for IIS 4.0 and 5.0". Make sure you follow the instructions for adding the PHP ISAPI module, otherwise this won't work!
    //
    //Side Effects:None
    //This code is copyrighted and has limited warranties.
    //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.252/lngWId.8/qx/vb/scripts/ShowCode.htm
    //for details.
    //**************************************
    
    require_once('db.inc');

    if (@$PHP_AUTH_USER == "" && @$PHP_AUTH_PW == "" && ereg("^Basic ", @$HTTP_AUTHORIZATION)) { 
    list($PHP_AUTH_USER, $PHP_AUTH_PW) = 
    explode(":", base64_decode(substr($HTTP_AUTHORIZATION, 6))); 
    }
    $authenticated = 0; 
    if (@$PHP_AUTH_USER != "" || @$PHP_AUTH_PW != "") { 
    	// Put the necessary code for checking username/passwords here.
    	$authenticated = $dbh->getOne("select count(*) from adminusers where username='" . $dbh->quoteString($PHP_AUTH_USER) . "' and password = '" . $dbh->quoteString($PHP_AUTH_PW) . "'");
    	// $authenticated = ($PHP_AUTH_USER == "test" && $PHP_AUTH_PW == "123"); 
    } 
    if(!$authenticated) { 
    	header("WWW-Authenticate: Basic realm=\"DB-Admin\""); 
    	if (ereg("Microsoft", $SERVER_SOFTWARE)) 
    		header("Status: 401 Unauthorized"); 
    	else 
    		header("HTTP/1.0 401 Unauthorized"); 
    	echo "Access denied"; 
    	exit; 
    } 
    ?>

db.inc
----------
<?php
	require_once "DB.php";
	$dbh=DB::factory("odbc");
	$rc = $dbh->connect("odbc://webuser:webuser@two");
	if (DB::isError($rc)) {
		echo "<html><head><title>Oops. We have a problem</title></head><body>\n";
		echo "Oh no, there is a problem with the database.  Please email ";
		echo "<a href=\"mailto:webmaster@sageconspiracy.com\">the webmaster</a> and ";
		echo "let them know what happened.\n";
		echo "<hr>\n";
		echo "<pre>", $rc->getMessage(), "</pre>\n";
		echo "<hr></body></html>\n";
		exit;
	}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-31 11:35 UTC] kalowsky@php.net
please try to include a simple sample script (read the bug tracker rules if you need more information).
 [2001-06-21 11:25 UTC] kalowsky@php.net
no user feedback.  
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 16:01:25 2019 UTC