#35245 [Fbk->Opn]: mysql_query not working when ob-Start() is called before

From: Date: Wed, 16 Nov 2005 18:57:21 +0000
Subject: #35245 [Fbk->Opn]: mysql_query not working when ob-Start() is called before
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88303@lists.php.net to get a copy of this message
ID: 35245 User updated by: walkekev at gmail dot com Reported By: walkekev at gmail dot com -Status: Feedback +Status: Open Bug Type: MySQL related Operating System: Linux PHP Version: 4.4.1 New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2005-11-16 19:24:15] 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:23:29] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35245&edit=1

« previous php.bugs (#88303) next »