• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Well read but still stupid Flash/PHP/MySQL sub-geek needs help before he goes bananas.

I've been reading tutorials, buying and reading books, and I still can't find anything that can show me how to get field contents from my MySQL table to show up as what they're supposed to be in my flash application at
http://www.improvlogic.com/karin_flash/bracelets.html.

Would anyone be willing to take me through what ought to be simple. It's not simple enough for me yet. And the more I read, the more confused I seem to get.

I just want the text area to get populated by what's in the database field rather than "undefined."

Thanks,

Karl
0
KarkofBlabs
Asked:
KarkofBlabs
  • 20
  • 18
  • +1
1 Solution
 
BillystyxCommented:
If you know the info is coming from the db, do you have a loadVars object in flash to collect it, and only go to the frame displaying the text once it is fully loaded?

billystyx
0
 
BillystyxCommented:
That would be the most common problem with this sort of thing - trying to display text before it has reached flash...
if this is the case and you need help with doing one, just ask me.

billystyx
0
 
KarkofBlabsAuthor Commented:
I believe that the info is coming from the db, and I have something of a loadVars object, though I probably coded it wrong.

-Karl

I could post the actionscript and the php so you could analyze my newbie gaffs.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BillystyxCommented:
yes, do that:)
0
 
sam85281Commented:
Haha, I need to get a T-Shirt of that headline:  "Well Read But Still Stupid" :)

-Sam
0
 
KarkofBlabsAuthor Commented:
Okay, here's my actionscript and then my disfuntcional PHP:

*************************Actionscript********************

on (reveal){

#include "NetDebug.as"

var test:TextFormat = new TextFormat();

description.setNewTextFormat(test);

var bracelet:LoadVars = new LoadVars();

bracelet.load("http://www.improvlogic.com/karin_flash/testbz001.php");

bracelet.onLoad = function() {
  description.text = this.bracelet;
};
}

*************************PHP********************
<?php
$hostname = 'MySQL4.SmarterLinux.com';
$username = 'improvlogic';
$password = 'lit0tes';

$sql = SELECT name FROM `bracelets` WHERE sku = 'BZ001';


db->close();
?>
************************************************

I know my PHP code is ridiculous but I've tried all sorts of other things that I've seen in tutorials and book. They all tell you how to make user registration things, games, and projects that are much more complicated and don't work in my MySQL implementation.

Please help me get this one field into the description field. Then I'm pretty sure I can see how to do the rest of it.

Thanks much,

Karl

P.S. Sam, if you help me solve my problem you can have all copyrights :)
0
 
BillystyxCommented:
starting with the as:
//text formatting needs some parameters of sorts (its css really) like:
var test= new TextFormat();
with (test) {
      font = "Tahoma";
      bold = true;
      color = 0x333333;
}
var bracelet = new LoadVars();

bracelet.sendAndLoad("http://www.improvlogic.com/karin_flash/testbz001.php",bracelet,"POST");

bracelet.onLoad = function() {
  description.text =bracelet.myVar;
description.setTextFormat(test);
};

then, php:

<?php
$connection=mysql_connect("MySQL4.SmarterLinux.com","improvlogic","lit0tes");
$db=mysql_select_db("yourdbname",$connection);//you need to know the name of your db for 1st param
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);

$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];

print($myVar);

?>

Billystyx
0
 
KarkofBlabsAuthor Commented:
Much appreciated. I'll give it a try tonight/tomorrow.

-Karl
0
 
KarkofBlabsAuthor Commented:
Uh oh!

Now my screens don't work properly and I get this in the output:

**Error** Screen=detailproduct:Line 14: Operator '=' must be followed by an operand
       description.text = bracelet.myVar;
**Error** Screen=detailproduct:Line 16: Statement must appear within on/onClipEvent handler
     };
**Error** Screen=detailproduct:Line 17: Unexpected '}' encountered
     }
Total ActionScript Errors: 3        Reported Errors: 3

Would it be helpful to you if you downloaded the files?

http://www.improvlogic.com/karin_flash/bracelets.fla
http://www.improvlogic.com/karin_flash/b_scroller_buttons.fla
http://www.improvlogic.com/karin_flash/testbz001.php

P.S. It is encouraging to get a more sophisticated class of error messages.
0
 
BillystyxCommented:
nice to see you are maintaining an optimistic outlook (instead of thinking options in terms of which window to throw the computer from..)
I will take a look... on ethhing though - I don't see the AS file above...

billystyx
0
 
BillystyxCommented:
... and the 1st fla is not on the directory above( so please upload again:), and the php all I need is a textfile - in fact what you have above is fine.
Can't send php like that because it processes as it goes.
btw, the php doesn't work - its giving an error anyway - can you post the code you have for that here too?

billystyx
0
 
KarkofBlabsAuthor Commented:
Dear billystyx:

Thanks for sticking with me.
I really think you need to see the files I'm "working" with. Because in addition to being "well read but stupid," I'm also one of those troublesome people who doesn't simply modify the examples from the books to make my projects look like everyone else's. And I absolutely loathe the "ComboBox." Thanks very much for sticking with me.
Please find the files at:

http://www.improvlogic.com/karin_flash/bracelets.fla
http://www.improvlogic.com/karin_flash/bracelets.html
http://www.improvlogic.com/karin_flash/bracelets.swf
http://www.improvlogic.com/karin_flash/testbz001.php
http://www.improvlogic.com/karin_flash/b_scroller_buttons.fla
http://www.improvlogic.com/karin_flash/b_scroller_buttons.html
http://www.improvlogic.com/karin_flash/b_scroller_buttons.swf
http://www.improvlogic.com/karin_flash/images_b/detail/bracelet_splash.fla
http://www.improvlogic.com/karin_flash/images_b/detail/bracelet_splash.swf
0
 
KarkofBlabsAuthor Commented:
Okay, here's the PHP file code. I guess the site won't let you download it.

<?php
$connection=mysql_connect("MySQL4.SmarterLinux.com","improvlogic","shirley");
$db=mysql_select_db("improvlogic",$connection);//you need to know the name of your db for 1st param
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);

$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];

print($myVar);

?>
0
 
KarkofBlabsAuthor Commented:
*****Okay, I fixed the login information in the php file:

<?php


$hostname = 'MySQL4.SmarterLinux.com';
$username = 'improvlogic';
$password = 'shirley';

$db=mysql_select_db("improvlogic",$connection);//you need to know the name of your db for 1st param
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);

$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];

print($myVar);

?>




*****And I got these errors now:

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 10

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 12

Warning: mysql_query(): A link to the server could not be established in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 12

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 14
&myVar=
0
 
BillystyxCommented:
looks like you forgot this line in the amended version:

$connection=mysql_connect("MySQL4.SmarterLinux.com","improvlogic","shirley");

billystyx
mysql_connect(and so forth...
0
 
KarkofBlabsAuthor Commented:
Billystyx:

Does it help to point out that I'm trying to get at a table called "bracelets" in my database called "improvlogic?"

-Karl
0
 
KarkofBlabsAuthor Commented:
*****When I put that line back in...

<?php
$hostname = 'MySQL4.SmarterLinux.com';
$username = 'improvlogic';
$password = 'shirley';
$connection=mysql_connect("MySQL4.SmarterLinux.com","improvlogic","shirley");
$db=mysql_select_db("improvlogic",$connection);
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];
print($myVar);
?>

*****I get these errors:

Warning: mysql_connect(): Access denied for user: 'improvlogic@10.10.0.53' (Using password: YES) in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 5

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 6

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 8

Warning: mysql_query(): A link to the server could not be established in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 8

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /vservers/improvlogic/htdocs/karin_flash/testbz001.php on line 9
&myVar=
0
 
mixartCommented:
I know this is slightly off topic but I would be careful posting your database name and password on the forums.  I suggest you change them :)
0
 
KarkofBlabsAuthor Commented:
mixart,

Do you think I need to change the database name too? I've already changed the password.

-Karl
0
 
BillystyxCommented:
Yes, probably a good idea (sorry, I assumed you had!)

I will have a look at this one today, sorry about the delay
billystyx
0
 
BillystyxCommented:
hello,
can you tell me where abouts in the swf the lines of code (from your above post (first)) are to be found?

->>on (reveal){

#include "NetDebug.as"

var test:TextFormat = new TextFormat();


reason I ask is, you sent me the flas, but if there is an included AS file - "NetDebug.as"
 -that is not with it this may be a problem.

Thanks,

billystyx
0
 
KarkofBlabsAuthor Commented:
Ah! "NetDebug.as" comes from
http://www.amfphp.org/ 
which I found out about at
http://www.macromedia.com/devnet/mx/flash/articles/amfphp.html

I tried this in a flash of sound reason as I was about to open the window to throw the computer out.

NetDebug is supposed to help you see what's going on when you try to do the exercise from macromedia devnet. It's like an extension. Of course, it didn't work as described in the article...sigh!

-Karl
0
 
BillystyxCommented:
fair enough then - bear with me (I have actually seen this template before somewhere... (I can't look until tonight (about 8 hrs), but can you tell me have you inserted the code I suggested into this one?If so, can you direct me to it (to save time for me:)

billystyx
0
 
KarkofBlabsAuthor Commented:
Okay, I coded everything as instructed (as far as I could understand) and I removed that NetDebug.as.
By the way, removing the NetDebug.as cured the problem I'd had with my screens.
Thanks again for sticking with me.
I look forward to hearing back from you when you can.

-Karl
0
 
BillystyxCommented:
cool - can you upload the fla you changed again - and I will pick it up tonight:)

0
 
KarkofBlabsAuthor Commented:
Okay, here's the php code:

<?php
$hostname = 'MySQL4.SmarterLinux.com';
$username = 'improvlogic';
$password = 'shirley';
$db=mysql_select_db("improvlogic",$connection);
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];
print($myVar);
?>

and here are the links to everything else:

http://www.improvlogic.com/karin_flash/bracelets.fla
http://www.improvlogic.com/karin_flash/bracelets.html
http://www.improvlogic.com/karin_flash/bracelets.swf
http://www.improvlogic.com/karin_flash/testbz001.php
http://www.improvlogic.com/karin_flash/b_scroller_buttons.fla
http://www.improvlogic.com/karin_flash/b_scroller_buttons.html
http://www.improvlogic.com/karin_flash/b_scroller_buttons.swf
http://www.improvlogic.com/karin_flash/images_b/detail/bracelet_splash.fla
http://www.improvlogic.com/karin_flash/images_b/detail/bracelet_splash.swf
0
 
KarkofBlabsAuthor Commented:
Are you still with me, BillyStyx?

-Karl
0
 
BillystyxCommented:
I did put the call out for help to others on this site - but noone has come in yet...
It keeps crashing me out - and I have to say, slides are not my area of expertise - so I don't know if its me doing something.

I am still with you, but at this point only in spirit:)

I don't know what to do.. I will see if I can get Negatyve to take a look...
Billystyx
0
 
KarkofBlabsAuthor Commented:
Thanks, I hope somebody can help me. You still get the copyright to "Well read but stupid." I ask only 10% of your gross sales.

So dig this. I called my web host tech assistants.
They told me to add ***
And now the PHP file works. I just now need to feed the data to Flash properly.

-Karl

<?php
$hostname = 'MySQL4.SmarterLinux.com';
$username = '';
$password = '';
***$connection = mysql_connect($hostname, $username, $password);
$db=mysql_select_db("",$connection);
$query="SELECT name FROM `bracelets` WHERE sku = 'BZ001'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$myVar="&myVar=".$row['name'];
print($myVar);
?>
0
 
KarkofBlabsAuthor Commented:
Please see whether somebody can now help me get the value to show up in my Flash application. I still need help with that.
Thanks,

Karl
0
 
BillystyxCommented:
OK, its not much, but its a start - on frame1 of bracelets, put this code and then test with ctl-enter:

loadVariables("http://www.improvlogic.com/karin_flash/testbz001.php","","POST");
onEnterFrame=function(){
      if(myVar.length>0){
            trace(myVar);
      }
}
your variable will show in the trace window

billystyx
0
 
BillystyxCommented:
and if you put a textfield on stage with variable name myVar, it shows up now.

I just don't understand all your panels, and how to get into where the textfields are in bracelet...
billystyx
0
 
KarkofBlabsAuthor Commented:
I'm glad it's working for you. I'm still lost.

The text areas are the text area components. They're in a screen named "detailproduct."
0
 
BillystyxCommented:
Did you try pasting the above code on frame 1 of the bracelet swf and then testing it?
What happened?

billystyx
0
 
KarkofBlabsAuthor Commented:
Yes, I put the code into frame 1 of the main screen called "bracelet_application."

I got the following errors. I guess I have to put it into an event handler.

**Error** Screen=bracelet_application, layer=action, frame=1:Line 3: Operator '=' must be followed by an operand
          if(myVar.length>0){

**Error** Screen=bracelet_application, layer=action, frame=1:Line 4: Syntax error.
               trace(myVar);

**Error** Screen=bracelet_application, layer=action, frame=1:Line 5: Syntax error.
          }

Total ActionScript Errors: 3        Reported Errors: 3
0
 
BillystyxCommented:
loadVariables("http://www.improvlogic.com/karin_flash/testbz001.php","","POST");
onEnterFrame=function(){
     if(myVar.length>0){
         description.text=myVar;//if description is where this is supposed to go, that's how you do it - pasting
//this code into frame1 of the third screen. I will upload what I have done...
     }
}

billystyx
0
 
BillystyxCommented:
0
 
KarkofBlabsAuthor Commented:
Wow! When I uploaded the published .swf to my web site's server and tested it, it did what I wanted it to do.

"Cuff Bracelet Red" also shows up in the "picture_loader" instance of the loader component. But this is wonderful.

Now I've got something to study and compare to all this other stuff I've been reading that has only tangential relationships to what I'm working on here.

Well done, billystyx.

Bless you!
0
 
BillystyxCommented:
no worries:)

(glad I finally got it sorted for you - hate it when I have trouble answering a question I start!)

good luck with it,
billystyx
0
 
KarkofBlabsAuthor Commented:
Yes, thanks again.
With what you've demonstrated, I believe I can figure out the rest of what I need to do.

-Kark of Blabs
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 20
  • 18
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now