PDA

View Full Version : Query in the Flash with PHP.


gilgames
07-11-2007, 09:55 PM
Hello.
I am trying to build a CMS with Flash + PHP showing dynamic content from MYSQL database.

My ActionScript code is this :
RightMouseButton.Tute(this);
var path = "http://djalmabina.orgfree.com/FLASH/ArtistCMS/";
System.useCodepage = true;
var loadInfo = new LoadVars();
loadInfo.id_user = 1;
loadInfo.onLoad = function (success)
{
if (success)
{
response(this);
trace (this);
}
else
{
response("CONNECTION ERROR");
} // end else if
};
initTXT = function ()
{
status_txt.html = true;
status_txt.autoSize = true;
};
response = function (str)
{
status_txt.htmlText = str;
};
initTXT();
response("LOADING DATABASE INFORMATION");
loadInfo.sendAndLoad(_root.path + "news.php", loadInfo, "POST");

and the PHP script is this :
<?
include 'includes/config.php';
include 'includes/db.php';

$user = $_POST['id_user'];
$date = $_POST['date'];
$text = $_POST['text'];

$sql="SELECT id_user,date,text FROM news";

$query = mysql_query($sql);

if (!$query) {
echo " It is not possible that query($sql) in MySQL: " . mysql_error();
exit;
}

if (mysql_num_rows($query) == 0) {
echo "Nothing found, exit !";
exit;
}


while ($row = mysql_fetch_assoc($query))
{
$user= $row["id_user"];
$date = $row["date"];
$text = $row["text"];
$results = $results+1;

echo "&loaduser$results=$user&<br>";
echo "&loaddata$results=$date&<br>";
echo "&loadtexto$results=$text&<br>";
}
unset($row);
mysql_free_result($query);

?>
When I call index.html with index.swf to display data, returns this screen:
http://djalmabina.orgfree.com/FLASH/ArtistCMS/index.html

This information not content text from the table, only codified.
What´s wrong, please ?

icktoofay
07-11-2007, 10:16 PM
This might help it... A bit... <?
include 'includes/config.php';
include 'includes/db.php';

$user = $_POST['id_user'];
$date = $_POST['date'];
$text = $_POST['text'];

$sql="SELECT id_user,date,text FROM news";

$query = mysql_query($sql);

if (!$query) {
echo " It is not possible that query($sql) in MySQL: " . mysql_error();
exit;
}

if (mysql_num_rows($query) == 0) {
echo "Nothing found, exit !";
exit;
}


while ($row = mysql_fetch_assoc($query))
{
$user= $row["id_user"];
$date = $row["date"];
$text = $row["text"];
$results = $results+1;

echo "&loaduser".$results."=".$user;
echo "&loaddata".$results."=".$date;
echo "&loadtexto".$results."=".$text."&ads=";
}
unset($row);
mysql_free_result($query);

?> And also... replace response(this); with response(this.loadtexto1); Or something like that. Just customize the as there.