Okay here's the code I have tried calling the file with the browser but no messages are displayed at all:
<?php
ini_set("always_populate_raw_post_data", true);
// Include the database details, and make a connection
include("../../my_includes/database.php");
$stmt = "SELECT subject, body, timestamp, first_name, last_name FROM my_posts, my_user WHERE my_user.id = my_posts.user_id ORDER BY my_posts.id ASC";
// Get all the posts and necessary information
$result = @($stmt, $db);
// Did we get a result?
if (!$result) {
echo "<?xml version=\"1.0\"?><XMLtest><error>SQL query failed. Please try again.</error></XMLtest>";
exit;
}
// Find the number of rows returned (i.e. the number of posts)
$numRows = @mysql_num_rows($result);
// Were there any rows?
if ($numRows <= 0) {
// No rows were returned, there mustn't be any entries
echo "<?xml version=\"1.0\"?><XMLtest><error>There are currently no entries in the database.</error></XMLtest>";
exit;
}
// Open the XML document
$XMLString = "<?xml version=\"1.0\"?><XMLtest>";
// Loop through each row and create the <message> node with all the correct information
for ($i = 0; $i < $numRows; $i++) {
$row = @mysql_fetch_array($result);
$XMLString .= "<message id=\"" . ($i+1) . "\"><author><firstName>" . $row['first_name'] . "</firstName><lastName>" . $row['last_name'] . "</lastName></author><time>" . $row['timestamp'] . "</time><subject>" . urlencode($row['subject']) . "</subject><body>" . urlencode($row['body']) . "</body></message>";
}
// Finish the XML document
$XMLString .= "</XMLtest>";
// Return the XML to Flash
echo $XMLString;
?>