php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11057 Premature end of script headers: c:/php/php.exe
Submitted: 2001-05-23 14:25 UTC Modified: 2001-06-24 17:16 UTC
From: baret at email dot cz Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.4 OS: Windows 98 SE
Private report: No CVE-ID: None
 [2001-05-23 14:25 UTC] baret at email dot cz
Im using Apache 1.3.14. I have problem with ODBC_functions, but I dont know why, problems appeared without any changes in source codes (related to the ODBC_functions).

I have predefined functions for ODBC_connect, ODBC_close, ODBC_query, ODBC_Fetch_Row and ODBC_result (written below). 
These functions are written in library.php, which is inherited in scripts by require.

require "library.php"


When Im using my functions, php crashes whith "premature end of script headers in c:/php/php.exe", but when Im using normal ODBC_functions, is everything allright. However it has been working normally, then "something happened" and it doesnt work.


	function connect()
	{
		@$con = ODBC_connect("MySQL","","");
		if(!$con) 
		{
			$error=1;
			include "error.php";
		}
		return $con;
	}

	function Query ($query)
	{
		global $conn;
		return ODBC_exec($conn, $query);
	}
	
	function Fetch_row ()
	{
		global $result;
		return ODBC_Fetch_Row($result);
	}
	
	function Result($field)
	{
		global $result;
		return ODBC_Result($result, $field);
	}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-23 10:10 UTC] baret at email dot cz
I tried to modify the functions so they have the same parametres as ODBC_functions and it works..

I didnt write before, that the only two functions, that are problematic, are Fetch_row and Result, other works properly.
 [2001-05-23 12:38 UTC] baret at email dot cz
I probably recognized the problem, my scripts generates sql queries like this (non-problematic version):

$query = "select count(*) cnt from tab01, tab11 where login='"
.$login.
"' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')";

I changed, so it should not be case sensitive for "login".

$query = "select count(*) cnt from tab01, tab11 where login='"
.strtolower($login).
"' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')";

but this didnt work, i tried also to convert to lowercase before using the converted string and that was also wrong.

$login = strtolower($login);

and then i used the first query.

So when I dont use converted strings, my functions works good, but when I use them, there is a problem described above.
 [2001-05-23 12:41 UTC] baret at email dot cz
I probably recognized the problem, my scripts generates sql queries like this (non-problematic version):

$query = "select count(*) cnt from tab01, tab11 where login='"
.$login.
"' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')";

I changed, so it should not be case sensitive for "login".

$query = "select count(*) cnt from tab01, tab11 where login='"
.strtolower($login).
"' and tab01.client_id = tab11.client_id and passwd=password('".$psswd."')";

but this didnt work, i tried also to convert to lowercase before using the converted string and that was also wrong.

$login = strtolower($login);

and then i used the first query.

So when I dont use converted strings, my functions works good, but when I use them, there is a problem described above.
 [2001-05-25 10:03 UTC] kalowsky@php.net
this really doesn't sound like a PHP problem to me.  you said it yourself when "using normal ODBC_functions everything is alright" (grammer corrected).  

regardless of that, if you're still convinced this is a PHP ODBC error, give me a SIMPLE sample script that i can use to reproduce this (about 10 lines or so), and what database you're using.
 [2001-05-26 03:55 UTC] baret at email dot cz
OK, here is the part of the script. Btw. i found, that this appears only if in query is agregate function count(*) (there are two types of query, one works good, other not)
Im using MySQL 3.23.27-beta with MyODBC driver. There is table tab01 with information about clients.
Script:

<html>
<head>
<title>Welcome</title>
<?
	function connect()
	{
		@$con = ODBC_connect("sample-MySQL","","");
		if(!$con) 
			echo "not connected";
		return $con;
	}
	
	function close ()
	{
		global $conn;
		ODBC_close($conn);
	}
	
	function Query ($query)
	{
		global $conn;
		return ODBC_exec($conn, $query);
	}
	
	function Fetch_row ()
	{
		global $rslt;
		return ODBC_Fetch_Row($rslt);
	}
	
	function Result($field)
	{
		global $rslt;
		return ODBC_Result($rslt, $field);
	}

if ($sent)
{
	$conn = connect();
	if ($conn)
	{
		$query = "select count(*) cnt from tab01 where login='".strtolower($login)."'";
//problematic

//		$query = "select * from tab01 where login='".strtolower($login)."'";
//works good
		$rslt = query($query);
		while(Fetch_row())
			$logged = Result("cnt");
		if ($logged)
			echo $login;
		else
			echo "not logged";
	close();
	}
}
?>
</head>
<body>
<form action="default.php">
<center>
<table>
<tr><td>Login: </td>
<td><input value="<?echo $login?>" type="text" name="login"></td></tr>
<tr><td colspan="2"><center><input type="submit" value="Submit"></center></td></tr>
</table></center>
<input type="hidden" name="sent" value="true">
</form>
</body>
</html>
 [2001-06-01 13:49 UTC] kalowsky@php.net
when you say it crashes what exactly does that mean?  do you still see the web server working and that message came up?  or did you get a nice core dump to show up with that statement on the screen popup?
 [2001-06-21 11:23 UTC] kalowsky@php.net
no user feedback.  please reopen the bug if you're still having trouble.
 [2001-06-24 17:16 UTC] baret at email dot cz
Im sorry. It means, that i see windows error, that there is an error in php.exe. Web server is still working, but in the log file is written aboud premature ending of ....

No HTML page is shown.
 [2003-01-30 14:49 UTC] dj_lucv at hotmail dot com
I'm using WinME, and also have troubles with this problem. I use mysql and mysql_fetch_object, I think the problem is the code is getting into a loop which never ends, sometimes I get an error 500, sometimes a endless page of the same error.
 [2003-02-02 10:44 UTC] dj_lucv at hotmail dot com
I've got a simple script, which creates the error:
<?PHP
if(isset($_GET['question'])){
	  $sql="SELECT id FROM pollv WHERE id='".$_GET['question']."' AND site='".siteid()."'";
	  $result=mysql_query($sql);
	  $id=0;
	  while($row=mysql_fetch_object($result)){
	  		$id=$row->id;
	  }
	  vraag($id);
}
?>
question=1, this one is in the database. In table pollv is one question with id=1. This script is to check the question belongs to the site used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC