Solved

loading image (Blob) files AND text from one php database table

Posted on 2003-10-27
3
239 Views
Last Modified: 2010-04-03
Hi

I have successfully loaded text from mysql php database but cannot get a picture (gif or jpg)
from the same database to load into the same movie clip.

can you help??

david

0
Comment
Question by:gangsidestep
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Calron
Comment Utility
Do you have the picure itself, the whole data stored in the database or just the filenames?
Flash does not have a way to read in bytestreams and construct the image inside of flash so you will have to construct it ourside of flash, easiest probably with php. Then either send it directly to flash from the php as a jpg, or save it as a temp file and pass the filename to flash.

Please tell me a bit more about how you have the images saved so I can help you out with your case.
0
 

Author Comment

by:gangsidestep
Comment Utility
my images are stored in the database in BLOB form.
my php file looks like this

 <?php
mysql_connect("localhost","xxxxxxx","xxxxxxxx");
mysql_select_db("xxxxxxx");
$query = "SELECT * FROM concerts";
$result = MySQL_query($query);
While( $rows = MySQL_fetch_array($result) )
{
$st = $rows["date"];
$stamp = mktime(0, 0, 0, substr($st, 5, 2), substr($st, 8, 2), substr($st, 0, 4));
$venue = $rows['venue'];
$address = $rows['address'];
$hyperlink = $rows['hyperlink'];
$logo_file = $rows['logo_file'];

echo ("&date=".date("l F dS Y", $stamp)."&venue=$venue&address=$address&hyperlink=$hyperlink&logo_file=$logo_file");
}
MySQL_close()
?>

That gives ma a string that looks like this:

&date=Tuesday November 18th 2003&venue=Arlene Grocery&address=95 Stanton St.&hyperlink=&logo_file=arlenes.gif&date=Tuesday November 18th 2003&venue=Arlene's Grocery&address=95 Stanton St. - NY&hyperlink=http://www.arlene-grocery.com&logo_file=GIF89aÈ#ÕfÌ™33333ÌÌf™†††3™Ìf3ÿ33fÌÌf™™333ÿ™3UUUÌ33™ÌfÌÿ3ÿf33fÿÌ3f333ÌÿÌ™33f™3fff™Ì"""Ìf3™f3™ÌÿBBBff3fffffÿÌf3™™Ì™fwww)))MMM!ùÿ,È#ÿ@€pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËí:«’U¡m6¡à‘15ÕD¨ÜµV«¥........"etc...etc"

I tried adapting the following php file from an example I found somewhere else and it worked fine even displaying the picture itself
when you opened the php file in a browser as long as the picture was the only element in the string.
But when I imported that code into my php file I keep getting an error message which says the header can't be changed


<?
$db = @mysql_connect(localhost, xxxxxx, xxxxxx) or
   die("Can't connect to server.");

@mysql_select_db("xxxxxx", $db) or
   die("Can't select database.");


$get_image = "select binary_junk,
   filetype from images where img_id = 1";

$get_image_result = @mysql_query($get_image)
   or die("Couldn't get image.");


$binary_junk = @mysql_result
($get_image_result,0,"binary_junk");

$filetype = @mysql_result
($get_image_result,0,"filetype");

header("Content-type: $filetype");
echo "$binary_junk";
?>


Thanks
David
0
 
LVL 5

Accepted Solution

by:
Calron earned 250 total points
Comment Utility
What you have to do is make two calls. One to read in the text from the first php file. And the second to read in the jpg script. If the jpg script works in the browser, then you should be able to load it in as a picture into flash as well. But there is no way you can combine the text and the picture into one call, as flash either loads text, or pictures. To make sure that you have the same record for the picture and you could send along the some kind of id to the picture script,that way you can load that specific image into the script.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now