php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35245 mysql_query not working when ob-Start() is called before
Submitted: 2005-11-16 19:23 UTC Modified: 2005-11-24 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:0 of 0 (0.0%)
From: walkekev at gmail dot com Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 4.4.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: walkekev at gmail dot com
New email:
PHP Version: OS:

 

 [2005-11-16 19:23 UTC] walkekev at gmail dot com
Description:
------------
The script will not do my sql statement if the ob_start() is called before my sql statement

Reproduce code:
---------------
<?php // first page of code
$name = basename($_FILES['userfile']['name']);
	$filename = $_FILES['userfile']['tmp_name'];
	$data = file_get_contents($filename);
	$filedata = mysql_real_escape_string($data);
	list($width, $height) = getimagesize($filename);
	$sql = "INSERT INTO `pictures` ( `id` , `name` , `height` , `width` , `type` , `data` ) VALUES ( '', '$name', '$height', '$width', 'a', '$filedata')";
	mysql_query($sql);
	require('./code/obufthumb.php');
	require('./database/sql.php');
 	$sql = "INSERT INTO `pictures` ( `id` , `name` , `height` , `width` , `type` , `data` ) VALUES ( '', '$name', '$newheight', '$newwidth', 'b', '$filedata')";
	mysql_query($sql);
?>
<?php // this is obufthumb.php
if($height > $width){
	$newheight = '120';
	$newwidth = '120' / $height * $width;
	}
else{
	$newwidth = '120';
	$newheight = '120' / $width * $height;
	}
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ob_start();
imagejpeg($thumb, NULL, 100);
$filedata = ob_get_contents();
ob_end_clean();
?>

Expected result:
----------------
is should insert 2 images into the database, one that is no more then 120px wide or tall.

Actual result:
--------------
it only inserts one into the database, the first one, with type a.

when i remove the ob_start() and ob_end_clean() it will work, both wil be inserted, but all the code of the jpeg is inserted into my screen

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-16 19:24 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2005-11-16 19:57 UTC] walkekev at gmail dot com
the script is availbe to view here http://phppa.lngdonline.com/view.php?file=admin.php
http://phppa.lngdonline.com/view.php?file=./code/obufthumb.php
 [2005-11-16 20:04 UTC] tony2001@php.net
Please provide a *SHORT* but complete reproduce script, that is max. 10-20 line long.
Thanks.
 [2005-11-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 17:01:35 2024 UTC