Hello all,
I am trying to connect to a MySQL database using PHP in Flash CS3 using Actionscript 3.
I have written the PHP file and some AS3 code and it displays the information but for some reason it also displays the tags. Can any one help?
This is my PHP code:
<?php require_once('Connections/pembrokeshire_diving.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_pembrokeshire_diving, $pembrokeshire_diving);
$query_shipwrecks = "SELECT * FROM wrecks";
$shipwrecks = mysql_query($query_shipwrecks, $pembrokeshire_diving) or die(mysql_error());
$row_shipwrecks = mysql_fetch_assoc($shipwrecks);
$totalRows_shipwrecks = mysql_num_rows($shipwrecks);
?>
<?php echo "<?xml version='1.0' encoding='utf-8'?>"?>
<dives>
<?php do { ?>
<wrecks>
<ship><?php echo $row_shipwrecks['Name']; ?></ship>
<sunk><?php echo $row_shipwrecks['Date']; ?></sunk>
<dep><?php echo $row_shipwrecks['Depth']; ?></dep>
<loc><?php echo $row_shipwrecks['Location']; ?></loc>
</wrecks>
<?php } while ($row_shipwrecks = mysql_fetch_assoc($shipwrecks));?>
</dives>
<?php
mysql_free_result($shipwrecks);
?>
This is my Actionscript 3:
[LEFT][LEFT][COLOR=#993300]stop[/COLOR]COLOR=#000000[/COLOR];
Security.[COLOR=#993300]allowDomain[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"*"[/COLOR], [COLOR=#0000ff]“localhost:8888”[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]var[/COLOR] dives_xml_url:[COLOR=#993300]String[/COLOR] = [COLOR=#0000ff]“http://localhost:8888/pembrokeshire_diving/generate_shipwrecks_xml_file.php”[/COLOR];
[COLOR=#993300]var[/COLOR] dives:[COLOR=#993300]XML[/COLOR] = [COLOR=#993300]new[/COLOR] [COLOR=#993300]XML[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#993300]var[/COLOR] dives_url:URLRequest = [COLOR=#993300]new[/COLOR] URLRequestCOLOR=#000000[/COLOR];
[COLOR=#993300]var[/COLOR] divesLoader:URLLoader = [COLOR=#993300]new[/COLOR] URLLoaderCOLOR=#000000[/COLOR];
divesLoader.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]COMPLETE[/COLOR], divesLoaded[COLOR=#000000])[/COLOR];
[COLOR=#993300]function[/COLOR] divesLoadedCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
dives = [COLOR=#993300]XML[/COLOR]COLOR=#000000[/COLOR];
shipname_txt.[COLOR=#993300]text[/COLOR] = dives.[COLOR=#000000]wrecks[/COLOR].[COLOR=#000000]ship[/COLOR];
date_txt.[COLOR=#993300]text[/COLOR] = dives.[COLOR=#000000]wrecks[/COLOR].[COLOR=#000000]sunk[/COLOR];
depth_txt.[COLOR=#993300]text[/COLOR] = dives.[COLOR=#000000]wrecks[/COLOR].[COLOR=#000000]dep[/COLOR];
locate_txt.[COLOR=#993300]text[/COLOR] = dives.[COLOR=#000000]wrecks[/COLOR].[COLOR=#000000]loc[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/LEFT]
The picture below shows what happens when I test the movie.
I also need to add buttons to move to the next and previous record and to add or edit the database via the Flash interface?
Any help would be really, really appreciated.
Gale