PDA

View Full Version : mysql_fetch_array and loadVars


SimpleCoat
12-01-2006, 11:27 AM
I've got a small custom "blog" set up.

An input field sends text to the db w/ PHP and a dynamic text field is SUPPOSED to pull all the text from that column of my db Table.

It works when I run the PHP file in the browser, but Flash can't seem to see it. I've tried sending it back to Flash as a name=value pair, and as a straight echo, but neither seems to work.

I have a feeling the problem is my code is too simple to deal with multiple values for one loadVar.

Here's the PHP code that calls the db and pulls all the entries from the column 'blogBody' in the table 'blogText'


<?
$user = 'simplec_admin';
$password = 'eugene';
$database = 'simplec_blog';

mysql_connect('mysql12.ixwebhosting.com', $user, $password);
mysql_select_db($database);

$query = 'SELECT * FROM blogText';
$blogQuery = mysql_query($query) or die('error');

//$display = mysql_fetch_array($blogBody) or die('error2');
while($blogDisplay = mysql_fetch_array($blogQuery)){
echo $blogDisplay['blogBody'];
echo "<br>";
}
?>


is "mysql_fetch_array" incompatible with loadVars in Flash, because it returns more than one value?

Here's my Actionscript that pulls the text from the PHP file and puts it in a dynamic text field:


var blogIn:LoadVars = new LoadVars();
var blogOut:LoadVars = new LoadVars();

blogIn.load("blogIn.php",_blank);

blogIn.onLoad = function (success) {
if(success){
blogField.text = blogIn.blogDisplay;
}else{
blogField.text = 'Error loading from Database';
}
};


Thanks a ton! x-posted in ACTIONSCRIPT 2.0 +GENERAL QUESTIONS (if only I had scrolled all the way down...there's a forum here just for me!)

Cota
12-01-2006, 07:51 PM
Something like

while($blogDisplay = mysql_fetch_array($blogQuery)){
$myBody .=$blogDisplay['blogBody'];
$myBody .= "<br>";
}
echo "&myBody=".$myBody;


and Flash

if(success){
blogField.text = this.myBody;
}else{
blogField.text = 'Error loading from Database';
}


But you get the general idea..