Displaying Images In Flash From Mysql

OK Guys,

I am very very stuck
:hair:


I have 10 placeholder movieclips for images inside of a main swf.

I need to load 10 images N2 these placeholders from a Mysql database.

Theres are also dynamic text fields that gives discriptions for each image.

The dynamic text is working fine.

Now the images are all in an . . . /image folder and the Mysql database has the filenames of each pic 1jpg, 2jpg, etc … . .

I need to know the specifically how to grab the images from the database so it will be consistant with the discription information coming out of the database through php.

I have over 500 rows in the database and each page displays 10 results. Also, I have the “previous/next” buttons to scroll through the database working

I need to know how to get those images into flash and correspond them with the description!!!

I need the php
and the actionscript for the movieclips.


Ive been to phpforflash, flashkit, flashdb, macromedia, this site – everywhere, and I cant find it how to do this!!!

It’s been about 2 weeks trying to figure this out and I am going a little crazy!!!

by the way/ I think this is one of the best forums ive come across

I am new here and would like to park it for a while

:wink:

HELP!!!

mages into the placeholder movieclip in a ma:cyclops::cowboy:

Is there anyone who can help me?

I am like banging my head up against the wall here!!

:slight_smile:

Don’t bang, post your fla and php to see how you do this…where’s the pb, did you trace what ph sends you?..I don’t know how you set this up, so hard to help…
And under what name did you post over at phpforflash? (if you did…)

ok
Actually its a simple question

How in the heck do you display images in a movieclip from a mysql database???

I dont understand the php
or the actionscript

Im storing the name of the jpegs in the database.
Im not storing the images directly into the database blobs

I can store and retreive text but not images. It’ weird!!!

Tried phpfored advanced cookbook - I still dont get it and I went over it like 10 times or so – lol

Am I am idiot or what – lol

Ah, ok, should’ve told me it’s the cookbook in the 1st place :slight_smile:
There’s osme errors in that code, did you check the support forums at phpforflash?
Actually, make sure you’re using non-progressive jpg’s (look just the same, but progressive ones won’t load!), then try using a full url, as in h**p://www.yoursitecom/images/whatever.jpg; loading them can be done in just one line:
this.createEmptyMovieClip(“img_mc”, 0).loadMovie(“my.jpg”);
then go to http://www.variablelimit.com and check the example files from the book, there’s a working version there, test that & let me know…

edit: jeremy removed his downloads, i’ll check my hd for you…

Ok, I have the files, but i need your mail, too large to attach here. PM-me.

Wait!!! — lol

:wink:

I have the the new cookbook files and I love the program!!!

Actually, I would like to impliment some of the category/search features n2 my site.

Anyway, I just dont understand how the pictures are comming out of the database and loading into the flash movie.

I’ve studied the code for days and I just dont get it

What/how do I put in the actionscript ???
What code do I use for php??

The cookbook ex is a little to advanced for me and he has alot of other dynamic information in his code. I cant tell what code is the picture load movie code vs. loading the other data.

I just need a simple run of the mill way to --well for now–

to load one pic into a movieclip from a database.

That would help me alot.

ok, then in your db, for each pic, store in a field imgUrl the (full) path to the image.
associated with the img’s id, you can easily get that…i hope, how much PHP => mySql do you know?
So, in Flash, empty holder (or AS as per above with createEmpty…blabla). Button or whatever to click on => loadVariables(“imageGet.php?imgID=X”) , X being a number set with btn click
then in PHP, connect to db, query: select * from images where imgID=X
from the result array, extract imgUrl and you’re set:
$link="&imgUrl=yourlinkhere&";
echo $link; (back to flash)
in flash: loadMovie(imgUrl, target);

or, populate all the details dynamically, with a drop-down for example where the labels are the img name, and the data the url, then the changeHandler will use
loadMovie([selected.getData()]); …something along those lines…
just format the db-output you send to flash from php as you need it…
are you following/able to code that (give it a-nother try…)
lemme know…

see next message

zammzammbamm@hotmail.com

This file might help in me understanding how to load pics from a database

her is my php code

$query = "SELECT * FROM users";		

$result = @mysql_query($query);
$count = 0;
$output = "";

while ($row = mysql_fetch_array($result)) {

$Pix = stripslashes($row['Pixs']);		

$Cut = stripslashes($row[‘Cut’]);

$output .= "&pixs" . $count . "=" . urlencode($pixs);			
$output .= "&members" . $count . "=" . urlencode($members);			
$output .= "&location" . $count . "=" . urlencode($location);		
    $count++;
}

echo $output . "&records=" . $count . "&result=Okay&";

?>


Now in my Mysql database I entered pics as 1.jpeg 2.jpeg etc . . .into a pics field
How do I target my image folder???


Here is the actionscript

stop ();

count = 0;

if (Number(records) == 0) {

disp_location1 = "";		
disp_members1 = "";
disp_Pixs1 = "";	

status = "No entries";

} else {

disp_location1 = this["location" add count];
disp_members1 = this["members" add count];
disp_Pixs1 = this["Pixs" add count];


status = "Entry " add (count+1) add " of " add Number(records);

}

count = 1;

if (Number(records) == 0) {

disp_location1 = "";		
disp_members1 = "";
disp_Pixs1 = "";	

status = "No entries";

} else {

disp_location2 = this["location" add count];
disp_members2 = this["members" add count];
disp_Pixs2 = this["Pixs" add count];
status = "Entry " add (count+1) add " of " add Number(records);

}

count = 2;

if (Number(records) == 0) {
disp_members2 = “”;
disp_location2 = “”;
disp_Pixs2 = “”;

status = "No entries in guestbook";

} else {
// Display first record returned

disp_members = this["members" add count];
disp_location = this["location" add count];	
disp_Pixs3 = this["Pixs" add count];
status = "Entry " add (count+1) add " of " add Number(records);

}

etc . . . .


I would like the pixs to load on enter frame so where do I put this???

loadVariables(“imageGet.php?imgID=X”)

On the first frame?
inside this actionscript??
And . . .
imgID-X —> I am still unclear as to what X is


loadMovie(imgUrl, target);

what is the imgUrl???
Is it the image name??
Is it the path name to the image folder??


I am displaying 10 records from the database and to move through the database the user
clicks on previous/next botton. So there are 10 images on each “flash page”

Also, I love your message board
very creative!!!

I downloaded kingfishers board
everything works but it doesnt display the correct number of tops
When you insert a new topic it stays at “0 topic”

Anyway, here is my short version of the actionscript and the
php file

X being a number set with btn click

Your PHP is very inconsistent…
First you got
$Pix = stripslashes($row[‘Pixs’]);
then you use
$output .= “&pixs” . $count . “=” . urlencode($pixs);
but $Pix is not equal to $pixs !?
(remeber, variable names in PHP are case sensitive, $pix != $Pix)
You define $Cut, but don’t use it, you use $members and $ location but don’t define them…hmm…is that a copy of what you use?
Also, in your query, there’s no LIMIT, whereas you say you display 10 records per page…?

In your AS, use a LOOP!!
No need to write that many if’s: [AS] for (i=0; i <Number(records); i++)…[/AS]

I would like the pixs to load on enter frame so where do I put this???

…on enterFrame of what?

It’s all not so clear, if you send me the fla & php, i’ll fix it, got no time to make up an example, sorry.

It all depends on how you set up the fla, you can either set for example
baseLoc=“http://www.yoursite.com/images/
and then just store the image name in the db as “1.jpg” etc,
and loadMovie(baseLoc add imgUrl, target);

The kingfischer board has many bugs in the code… the new one (currently up on phpforflash) is also free now, get it from www.dynamicflash.co.uk (steve’s blog)

ok here is the .fla. I also included the php and sql. It’s pretty big, sorry. Anyway, let me know.

Could someone do a tutorial on this issue, images, mysql and flash???

Here is a tutorial from actionscript-toolbox.com which should hopefully end all your woes! The url is:

http://www.actionscript-toolbox.com/samplemx_loadjpg.php
(or)
http://www.actionscript-toolbox.com/samplemx_php.php

Hay thax for the suggestion!!!

I’ve been through that script 100x’s and broke it apart
to find just how and where the code is for the database-php-image thing.

I’ve had no luck with the tutorial at all!!!

It gets very confusing when she mixed the functions of the url buttons with the image code.

No luck with that tut

I’ve search all over the net and well
it’s just not clicking with me

HELP!!!

why isnt this working for me??

I have a movie with an empty MovieClip in Stage with instance name “target”. My database have a table named Images, with a column named pic.

In the database I have 1.jpg 2.jpg 3.jpg etc . . .

Actionscript

//Frame 1
myData = new loadVars()
myData.load(“getImage.php”)
myData.onLoad = function(succes){
if(succes){
target.loadMovie(this.pic)
} else trace(“error: couldn’t load from database”)
}

PHP
<?php
$Connect = mysql_pconnect($hostname, $username, $password) or die(mysql_error());
mysql_select_db(“database”, $Connect);
$result = mysql_query(“select pic from Images LIMIT 1”); //just one image
$image = mysql_fetch_array($result);
echo “pic=$image[‘pic’]”;

whats wrong with this??

I have been trying to load a silly jpeg from a database n2 flash for a month now and nothing is working for me.

I’ve tried every flash forum, every php forum, every book and I still cannot get this thing to work.

can anyone help me or am i a ghost like my smilie???

:run:

Here is my fla with included db

Help

SOS

:trout:

OK

didnt get any help on the last zip file

here is a more simpler example

I can load an image into flash from php

but i cant seem to load it from mysql via php

here is a very very simple example as to what my code is

anyone help me please!!!

I am so darn close!! :eye:

ok.
from your php:
"…
// Build and execute query
$query = "SELECT * FROM imagetable;
=>1/ you build, but you never excute the query!

$pic1 = “/images/pic”;
$pic2 = “/images/pic”;
$pic3 = “/images/pic”;
$pic4 = “/images/pic”;
$pic5 = “/images/pic”;
=>2/ you don’t use the query’s results to set up your output, you just set it yourself, what’s the whole db for then?

echo “&pic1=$pic&”;
=>3/ this should be “&pic1=”. $pic1; where $pic1 is one of the query’s results
…"

here’s an example of how it should look:

 // Build query to return catagory list...
$query = "SELECT * FROM forumCatagories ORDER BY displayOrder";

// Execute query
$result = @mysql_query($query);

if (!$result) {
    fail("Couldn't fetch catagory list");
}

// Fetch number of catagories
$catagoryCount = mysql_num_rows($result);

// For each catagory returned...
for ($count = 0; $count < $catagoryCount; $count++) {
    $catagory = mysql_fetch_array($result);

    // Output data
    print "&catagory" . $count . "ID=" . $catagory['catagoryID'];
    print "&catagory" . $count . "Title=" . urlencode($catagory['title']);
}

// Output catagory count...
print "&catagoryCount=$catagoryCount";

Hay, thanx alot for your help!!!

Been trying to get code to work all day

still no luck

here is my new simple code

<?PHP
$Connect = mysql_pconnect($localhost, “”, “”) or die(mysql_error());
mysql_select_db(“aboy”, $Connect);
$result = mysql_query(“select * from image”);
$image = mysql_fetch_array($result);
echo “pic=”.$image[“pic”];
//send it to flash
?>

in the database I have just 1 pic in database 1.jpg

database: aboy
table: image
field: pic

why isn’t this working???

and how do I call the image from the /image folder???

I AM SOOOOO CLOOOSSSEEEEEEEEEE :mario: