Forum Moderators: coopster

Message Too Old, No Replies

MYSQL BLOB and imagecreatefromstring and headers warning

         

nagmier

3:33 am on Oct 18, 2006 (gmt 0)

10+ Year Member



case 'search_title':

echo '<form enctype="multipart/form-data" action="./admin.php?page=item&action=search_title" method="post">';
echo '<div align="left">Title:</div><input name="item_title" type="text" id="item_title" size="50" />';
echo '<input type="submit" name="Submit" value="Submit"/><input type="hidden" name="title_submitted" value="TRUE" /></form>';
if (isset($_POST['title_submitted'])){
//QUERY THE DATABASE
echo 'Ran!';
$query = 'SELECT * FROM items WHERE MATCH (i_title) AGAINST (\'' . $_POST['item_title'] . '\' IN BOOLEAN MODE)';
$result = mysql_query($query);
while($r = mysql_fetch_array($result)){
echo '<p>' . ($r['i_title']) . '</p>';
echo '<p>' . ($r['i_sport']) . '</p>';
echo '<p>' . ($r['i_type']) . '</p>';
echo '<p>' . ($r['i_location']) . '</p>';
echo '<p>' . ($r['i_description']) . '</p>';
echo '<p>' . ($r['i_cost']) . '</p>';
echo '<p>' . ($r['i_shipcost']) . '</p>';
$img1 = imagecreatefromstring($r['i_pic1']);
$img2 = imagecreatefromstring($r['i_pic1']);
header('Content-Type:image/jpeg');
header('Content-Disposition: inline, filename:file.jpg');
echo '<img src="';
echo imagejpeg($img1);
echo ' ">';
//echo '<img>' . imagejpeg($img2) . '</img>';
}
}

break;

That is the excerpt I have checked all of my files includes and all for extra chars at the beginning and end of the php tags and they look fine it only seems to happen here

What I'm trying to do is get my jpeg blob from my database (which it pulls perfectly) and convert it back to a jpeg to use in my page... here is where the problem is I only get the binary code and with the header statements I get the all too common headers error... any ideas I am using dreamweaver 8 to edit the php code ( I need to get off my you know what and download notepad++ again...) but I think as far as the whitespace goes I'm good

eelixduppy

11:16 am on Oct 18, 2006 (gmt 0)



Your whitespace may be good, however you are echoing text to the browser. Comment all of the echo statements out before the header [us2.php.net] function call and you should be fine, although I didn't check the rest of your code for errors; I just noticed this one right away ;)

By the way, Welcome to WebmasterWorld!

P.S. Another solution is to put everything into a buffer [us3.php.net], and echo it out after you set the headers.

nagmier

8:38 pm on Oct 19, 2006 (gmt 0)

10+ Year Member



Thanks but I decided this wasn't going to be worth while and decided to just store the link references in mysql

eelixduppy

9:05 pm on Oct 19, 2006 (gmt 0)



Glad you found a solution. As long as it works for you ;)