Page 1 of 1

php, mysql, flash

Posted: Sat Jun 07, 2008 9:39 am
by kamcknig
Sorry if this isn't where I'm supposed to put this, first time on this forum, but my question pertains mainly to the php code of my app.

I have a database in MySQL that has a field that contains binary data for pictures that have been uploaded via a flash interface to the server.

I also want my flash interface to be able to view pictures receieved from the server. So the question is, I want to display 20 pictures at a time. Can I select 20 rows and then have php return all 20 at the same time in a way that can be parsed in flash? Or should I just make a loop in flash to call the retrieve script 20 times?

Thanks!
Kyle

Re: php, mysql, flash

Posted: Sat Jun 07, 2008 10:36 am
by Benjamin
Kyle,

I believe what you'll want to do is create a php page that will send image headers and an image. So you'll send the image urls to flash in a format like <img src="http://domain/images.php?image_id=12" />

images.php will then pull the image with id 12 and send it to the flash application.

I don't know much about flash though so I have no clue if that will work for you but that is how you would do it for a web page.

Re: php, mysql, flash

Posted: Sat Jun 07, 2008 10:45 am
by kamcknig
that's a pretty decent idea, though i think i'd have to change around my databases. currently i'm storing the image as binary data in a blog field. so i was hoping i could just like, string the binary datas together with some delimiter or somethiung and parse in flash.

so if i use your way, instead of storing binary data in a field, i should upload/save the picture on the server and then put the file name in the field?

Thanks for the response!

Re: php, mysql, flash

Posted: Sat Jun 07, 2008 10:48 am
by Benjamin
The php file could easily pull the image from the database and send it to the browser/flash application. You'll just need to use PHP's header function to send the appropriate image headers.

It is a much better idea however to store images on the file system rather than in a database for a number of reasons, namely performance.

Re: php, mysql, flash

Posted: Sat Jun 07, 2008 10:50 am
by kamcknig
Yeah, I was thinking of going that route anyway now :)

Thanks!