php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76968 error_log does not nt show correct ouput
Submitted: 2018-10-04 05:38 UTC Modified: 2018-11-18 22:38 UTC
From: forum at sodcore dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 7.0.32 OS: Debian
Private report: No CVE-ID: None
 [2018-10-04 05:38 UTC] forum at sodcore dot com
Description:
------------
 When error_log is run it addes extra lines to a variable like #12#11#11
 Yet code runs correctly.

Test script:
---------------
<?php
require "../standard/functions.php";
$d = "";
$temp = "data;";
// Check to make sure we have correct request method post and that the token key fits
if ($_SERVER ["REQUEST_METHOD"] == "POST" && ! empty ( $_POST ["T"] ) && $_POST ["T"] == $TOKEN_LOCK_HTTP_POST)
{
	if (!empty($_POST["d"]))
	{
		$d = $_POST["d"];
	}
	// define variables and set to empty values
	$con = get_database_connection ();
	// If there is a result echo the results
	$sqlStatment = prepare_sql("select * from table,table2 WHERE table.id = table2.id
		and table2.serial = '$d';");
	error_log($sqlStatment,0);
	if ($res = $con->query($sqlStatment)) {
		$res->data_seek(0);
		$totalRows = $res->num_rows;
		// Return the total number of rows
		if ($totalRows > 0) {
			while ($row = $res->fetch_assoc()) {
				$temp .= $row['f'];
			}
		}
		
		$res->close();
	}
	else
	{
		$temp .= "-100";
	}
	echo $temp;
}
?>

Expected result:
----------------
 I expect error_log to log:
 select * from table,table2 WHERE table.id = table2.id
		and table2.serial = '$d';
 But it logs:
 select * from table,table2 WHERE table#12#11#11.id = table2.id
		and table2.serial = '$d';

 Yet the code works correctly.
 The logging is messed up in more then one of my files.

Actual result:
--------------
But it logs:
 select * from table,table2 WHERE table#12#11#11.id = table2.id
		and table2.serial = '$d';

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-04 12:13 UTC] sjon at hortensius dot net
I cannot reproduce this. Do you have the same problem when you simply log the string directly? Maybe prepare_sql performs magic on it?
 [2018-10-04 12:16 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2018-10-04 12:16 UTC] kalle@php.net
It depends on what your prepare_sql() function would return, if it does any escaping or such, then it could be the reasoning for this behavior. Try var_dump($sqlStatement); before calling error_log() and see what it yields.

Seems more like an issue in your code, than a bug in error_log() itself
 [2018-10-04 12:16 UTC] kalle@php.net
-Package: Apache2 related +Package: *General Issues
 [2018-11-18 22:38 UTC] cmb@php.net
-Status: Feedback +Status: No Feedback
 [2018-11-18 22:38 UTC] cmb@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 11:01:28 2024 UTC