php, mysql, flash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kamcknig
Forum Newbie
Posts: 3
Joined: Sat Jun 07, 2008 9:37 am

php, mysql, flash

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: php, mysql, flash

Post 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.
kamcknig
Forum Newbie
Posts: 3
Joined: Sat Jun 07, 2008 9:37 am

Re: php, mysql, flash

Post 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!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: php, mysql, flash

Post 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.
kamcknig
Forum Newbie
Posts: 3
Joined: Sat Jun 07, 2008 9:37 am

Re: php, mysql, flash

Post by kamcknig »

Yeah, I was thinking of going that route anyway now :)

Thanks!
Post Reply