#45840 [Opn->Csd]: When you try to echo the contents of a BLOB it gives you a reference variable

From: Date: Sun, 17 Aug 2008 14:17:00 +0000
Subject: #45840 [Opn->Csd]: When you try to echo the contents of a BLOB it gives you a reference variable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128151@lists.php.net to get a copy of this message
ID: 45840 User updated by: trendboy at gmail dot com Reported By: trendboy at gmail dot com -Status: Open +Status: Closed Bug Type: MySQL related Operating System: Linux and Windows PHP Version: 5.2.6 New Comment: I think I may have fixed it, it seems to be the upload I had was the problem. Previous Comments: ------------------------------------------------------------------------ [2008-08-17 12:31:41] trendboy at gmail dot com Description: ------------ Steps to reproduce: 1) Create a page to read in a JPEG image from a URL location and inserts into the database to a BLOB. 2) On another page select * from your blob 3) Using any method, myself_fetch_array or assoc get the contents 4) Print or echo it out You get Resource ID #5 Dump the vars from the result record set and you get resource 3 type(mysql result) It's very strange! It should be displaying the content of the blob to the screen and with the correct mime header set to jpeg it should show you the image. I thought maybe it was a bug on the LINUX version so I installed the windows version and same issue. Linux version: /usr/local/php/bin/php --version PHP 5.2.4 (cli) (built: Sep 17 2007 22:46:56) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies mysql --version mysql Ver 14.12 Distrib 5.0.27, for pc-linux-gnu (i686) using readline 5.0 I tried 5.2.6 on windows. It's a right head-wrecker :) Is it a bug? Reproduce code: --------------- The code (shortened of course) my insert is (after I get it from a URL etc): mysql_query("insert into thumbnail (image) values ('" . addslashes($img) . "')"); then to read it: $sql = "select * from thumbnail where id = 1"; $result = mysql_query($sql); var_dump($result); while ($row = mysql_fetch_assoc($result)){ echo $row[image]; } Expected result: ---------------- You should see your image ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45840&edit=1

« previous php.bugs (#128151) next »