Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 03:06
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  PHP mySQL integration and Flash
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: PHP mySQL integration and Flash  (Read 3376 times)
tom
Server what's that
*
Posts: 19



View Profile WWW Email
« on: 02/03/02, 09:38 »

Hey,

This question is another one on printing text into a flash movie from a mySQL database. I want to have variable (ie. one field from within the table) text drawn from the database into the movie, but I recieve the message:

"resource id#2" back from the query. I know that it's connecting to the database because I don't recieve an error.

I'm sure there is something obviously wrong with the coding, but I can't for the life of me see what it is :( lol

Where it is in CAPS, I would put in my own info.

<?
 @ $db_conn = mysql_pconnect("localhost", "USER", "PASSWORD");

if (!$db_conn)
 {
    echo "Error: Could not connect to database.";
    exit;
 }

 mysql_select_db("DATABASE");
 $query = "select VARIABLE from TABLE";
 $result = mysql_query($query);
 if (mysql_num_rows($result) >0 )
{

Print "_root.textfield= $result"; //THIS LINE PRINTS IT INTO THE FLASH MOVIE

}

?>

Help on this would be greatly appreciated
Tom
Logged
flashswami
Jr. Programmer
**
Posts: 55


vene vidi vector


View Profile WWW
« Reply #1 on: 02/04/02, 04:14 »

Hi Tom Smiley

Your SQL looks a little suss to me. You have-

$query = "select VARIABLE from TABLE";

Which is a bit ambiguous. Select implies you are telling your db what to select from the table- i.e. select all or select a particular field. e.g.

$query="SELECT fieldname FROM tbl_tablename WHERE id='$variable'";

Also, you have your script printing-

Print "_root.textfield= $result"; //THIS LINE PRINTS IT INTO THE FLASH MOVIE

to the browser. I would have-

echo "textfield=$result";

Then, within Flash, load the variables into a target or level, as oppose to putting '_root' in your script.

Just my thoughts, hope they help (hope I've understood what you mean!).


Logged

Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #2 on: 02/04/02, 09:21 »

I usually use something like this:
Code:
<?php
require ('Includes/yourDBPassLogin.php');

mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db($DBName);

$result mysql_query("SELECT variable FROM table");

if (
mysql_num_rows($result) > 0){
         
$tmp mysql_fetch_row($result);
         print 
"textfield=$tmp[0]";
} else {
         print 
"textfield=No results found";
}

?>

You will have to specify which value to use from the result array.  In this case it's the first value - which is specified by $tmp[0].  The in require part would just contain your host, username, password etc.  

To test at first - try just typing in the URL to this php file in your browser.  If everything went correctly you'll see a simple string printed out to the page - this will be what Flash reads in.  
« Last Edit: 02/04/02, 09:22 by Jeff » Logged

-Jeff.
tom
Server what's that
*
Posts: 19



View Profile WWW Email
« Reply #3 on: 02/04/02, 10:30 »

Thank you so much both for your help, it's worked at last!

You guys! Smiley

I'll be back lol
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!