A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Replace lowercase with uppercase?

  1. #1
    Dumbass grBMXer's Avatar
    Join Date
    May 2002
    Location
    Grand Rapids, MI, USA
    Posts
    212

    Replace lowercase with uppercase?

    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
    [+] Website. http://www.evanbartlett.com/
    [+] Email. evan@evanbartlett.com
    [+] AIM. emDUB123456789
    [+] Yahoo! evanem1

  2. #2
    before you print the text, run strtoupper on the string to convert it to uppercase

  3. #3
    Dumbass grBMXer's Avatar
    Join Date
    May 2002
    Location
    Grand Rapids, MI, USA
    Posts
    212
    Thanks a ton! Can you possibly show me an example of the correct way to run this in my script? I'm not very good with string replacement.

    Evan
    [+] Website. http://www.evanbartlett.com/
    [+] Email. evan@evanbartlett.com
    [+] AIM. emDUB123456789
    [+] Yahoo! evanem1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center