PDA

View Full Version : Newbie Question About Getting Quotes from a Database (PHP/MX2004)


Northchild
09-09-2004, 02:04 AM
This is my first time integrating PHP with Flash, and I'm a bit unsure of myself. I'm using MX2004 and have PHP with MySQL support on a remote server. Overall, I'm trying to get a simple "random quote of the day" thing working.

Database has a table called allQuotes with one field named quotes.

Flash file has a dyamic text field named txtQuote on the main timeline, plus this code:


loadVariables("quotes.php", POST);


quotes.php has this code:


<?php
$link = mysql_connect(dbname, username, password) or die("Failed to connect to database.");
$query = "SELECT quotes FROM allQuotes ORDER BY RAND()";
$result = mysql_query($query) or die("Failed to execute query.");
$myQuote = mysql_fetch_array($result, MYSQL_ASSOC);
print "txtQuote=" . $myQuote[quotes];
?>


So far, I'm not able to get this to work... which is not surprising. Any advice greatly appreciated :)

Dark_Element
09-09-2004, 04:41 AM
Well. LoadVariables may be a bit slow for this task. try using LoadVars() with sendAndLoad(). Also mysql_fetch_array() may be slower and more server consuming since its fetching two sets of data, try mysql_fetch_assoc()