Im trying to retieve a data from my Mysql database via PHP and using flash as my display arae. My problem is passing a varibale from flash to PHP. That can be done.But mine is not working. My scenario is this i have several button on a separate .swf file which load another .swf file to the rigth part of my stage whenever a button is hit and unload that movie and load another .swf file when other button is hit. here is a the code on each button
on (release) {
_root.dostuff(x);
var id = "x";
loadVariables ("fetchclient.php?", "x.swf", "POST");
}
//where is is button number
//doStuff function does the loading and unloading of the movie
now i want to pass var "id" to php, so that ill use that as a query id to retieve my data
here is the code for my PHP.Look at my query
<?
// fetchcllient.php
// Define satabase connection details
$dbHost = "localhost";
$dbUser = "joseph";
$dbPass = "joseph123";
$dbName = "MDi";
$table = "clients_grp";
// Attempt to connect to MySQL server
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
// Attempt to connect to MySQL server
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
// If the connection was unsuccessful...
if (!$link)
{
// Report error to Flash and exit
print "&writeup=" . urlencode("Could not connect to server");
exit;
}
// Attempt to select database. If unsuccessfull...
if (!@mysql_select_db($dbName))
{
// Report error to Flash and exit
print "&writeup=" . urlencode("Could not select $dbName database");
exit;
}
// Build query to fetch client grp items from database
$query = "SELECT clients_grp.client_type, clients_grp.writeup, client.client_name
FROM clients_grp LEFT JOIN client ON clients_grp.client_grpid = client.client_grpid WHERE clients_grp.client_grpid = '$id'";
// Execute query
$result = @($query);
if ($result && @mysql_num_rows($result) > 0)
{
// Initialise variable to hold client grp items
$writeup = "";
$client_type = "";
$client_name = "";
// For each client grp item returned from query...
while ($row = mysql_fetch_array($result))
{
$writeup .= '<font align="left" face="Arial, Helvetica, sans-serif" color="#003399" size="10"><b>';
$writeup .= stripslashes($row['writeup']);
$writeup .= '</b></font><br>';
$client_type .= '<font align="center" face="Arial, Helvetica, sans-serif" color="#003399" size="12"><b>';
$client_type .= stripslashes($row['client_type']);
$client_type .= '</b></font><br>';
$client_name .= '<font align="center" face="Arial, Helvetica, sans-serif" color="#003399" size="10"><b>';
$client_name .= stripslashes($row['client_name']);
$client_name .= '</b></font><br>';
}
print "&writeup=" . urlencode($writeup);
print "&client_type=" . urlencode($client_type);
print "&clientText=" . urlencode($client_name);
}
else
{
// Tell Flash no news items were found
print "&writeup=" . urlencode("No clients items yet");
}
// Close link to MySQL server
mysql_close($link);
?>
when i run this i got the msg"No client items yet" and when i manually replace $id with a number say 1 it displays the content of my database to flash.What could be the problem ??Please help