Hey everyone.
I'm running a php script in my backend to fetch the news from the db and then flash reads the php file in. Basic stuff. It works fine so far. This is what I have.
PHP Code:
<?
// Define database connection details
$dbHost = "xxx";
$dbUser = "xxx";
$dbPass = "xxx";
$dbName = "xxx";
$table = "xxx";
// 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 "&textVar=" . 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 "&textVar=" . urlencode("Could not select $dbName database");
exit;
}
// Build query to fetch news items from database
// Using 'ORDER BY posted DESC' to fetch newest items first
$query = "SELECT * FROM news ORDER BY posted DESC";
// Execute query
$result = @mysql_query($query);
// If query was okay AND we have at least 1 news item...
if ($result && @mysql_num_rows($result) > 0)
{
// Initialise variable to hold news items
$textVar = "";
// For each news item returned from query...
while($row = mysql_fetch_array($result))
{
// Format date in 'mm/dd/yy' format
$posted = strftime("%m/%d/%y", $row['posted']);
// Add title to output
$textVar .= '<font color="#8598B2"><b>';
$textVar .= $posted . " | " . $row['title'];
$textVar .= '</b></font><br>';
// Add news item body with a double linebreak
$textVar .= '<font color="#888A8B">';
$textVar .= stripslashes($row['body']);
$textVar .= '</font><br><br>';
// EMAIL PARSER
$pattern = '/\[(email|EMAIL)=(.*?)\](.*?)\[\/(EMAIL|email)\]/';
$replace = '<a href="mailto:\\2"><font color="#8598B2"><u>\\3</u></font></a>';
$textVar = preg_replace($pattern, $replace, $textVar);
// URL PARSER
$pattern = '/\[(url|URL)=(.*?)\](.*?)\[\/(URL|url)\]/';
$replace = '<a href="\\2" target="_blank"><font color="#8598B2"><u>\\3</u></font></a>';
$textVar = preg_replace($pattern, $replace, $textVar);
// NEWLINE PARSER
$textVar = ereg_replace("\r\n", "<br>", $textVar);
}
// Output news items back to Flash
print "&textVar=". urlencode ($textVar);
}
else
{
// Tell Flash no news items were found
print "&textVar=". urlencode ("No news items yet") ;
}
// Close link to MySQL server
mysql_close($link);
?>
What I'm looking to do now is make it so when it brings it back it replaces and lowercase letters in the data with uppercase so my flash is all uppercase? I've tried the uppercase AS in flash and it works off and on and sometimes it loads it in lowercase and changes it before your eyes. Not very good looking I think.
My thinking is theres some sort of string replace but I'm not sure. That way it replaces it all before flash reads it. Get my point? Thanks alot!
Evan