# Random quote generator with Flash, PHP & MySQL

**URL:** <https://forum.kirupa.com/t/random-quote-generator-with-flash-php-mysql/204799>\
**Category:** programming\
**Created:** [October 23, 2006, 5:38pm UTC](https://forum.kirupa.com/t/random-quote-generator-with-flash-php-mysql/204799 "2006-10-23T17:38:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/smax/32/2916_2.png) [@Smax](https://forum.kirupa.com/u/Smax)\
**Post date:** [October 23, 2006, 5:38pm UTC](https://forum.kirupa.com/t/random-quote-generator-with-flash-php-mysql/204799/1 "2006-10-23T17:38:45Z")

</div>

I’m trying to create a random quote generator which loads quotes from a MySQL table into a Flash dynamic text field.

I have this PHP code:

```php
<?
$username="my_username";
$password="password";
$database="my_database";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$get_count = "SELECT COUNT(id) FROM facts";
$count_result = mysql_query($get_count)
or die ("Couldn't get count.");
$count = mysql_result($count_result, 0, "COUNT(id)");

srand((double)microtime()*1000000);
$random_id = rand(1, $count); 

$get_fact = "SELECT fact FROM facts where id = '$random_id'";
$fact_result = mysql_query($get_fact)
or die ("Couldn't get quote.");
$fact = mysql_result($fact_result, 0, "fact"); 

$send_fact = "fact=";
$send_fact .= rawurlencode($fact);
echo "$send_fact";
mysql_close();
?>

```

…which seems to work at least partially as I can see the url-encoded string with the quote if I view the php file.

The tutorial I used to do this suggested the ActionScript:

```auto
loadVariables("http://www.theresmoretolifethanshoes.com/quotes.php", fact);

```

… where my dynamic text box has the instance name of “fact”, but this isn’t working. The box comes up blank.

Any clues as to where I’m going wrong (or suggestions of any more up to date tutorials covering this) would be hugely appreciated. 🙂
