Hey, You found me.

Welcome to my site. I am a filipino web designer who's been creating web designs for 10 years. This is where I usually stash my selected art works, projects, and random thoughts.

More
Codes
30Jul2009

Wordpress, Flash, and IE

To tell you the truth, I really don’t like using IE but it’s part of my job. Being a web designer, I want to familiarize myself with anything related on creating a web site. Cross-browser compatibility is one of them. It’s been a while since I’ve touched ActionScript and my knowledge is almost obsolete. Thus, I’ve been trying to self-study AS3. I know, I love using wordpress and I love Flash as well, so why not try to combine them?

The past few months, I’ve been using my spare time to test what I’ve learned to create a full flash site with wordpress as its CMS. I am not as good as those PHP programmers or Flash developers but I get by. So anyway, I encountered a problem when I checked my page in the IE browser. The IE doesn’t seem to recognize the XML being displayed by my PHP code. I’ve been trying to figure out why IE doesn’t get to parse a XML output from php that a Flash is accessing. It worked the first time but when I cleared the IE’s cache it revert back to my first problem.

It took me a while to figure out that the file I used to connect to wordpress “wp-pass.php” is the one ruining the mime header that I used for IE.
Figuring a way to access the database, I tried calling the wp-config.php to get the information and created my own function to connect to the database. The other day, a friend of mine said that that’s not the most safest way to connect to wordpress’ database. I’m just a designer trying to do some coding on my own so I can’t really deny his comment.

Here is a screenshot of the page in Firefox. Here’s another screenshot of the page in Internet Explorer. This is the XML output from the function I created.

This is my code in the php.

  1. <?php
  2. header(“Content-type: text/xml”);// Sets mime-type
  3. /** Loads the WordPress Environment and Template */
  4. require(‘../../../wp-pass.php’);
  5. $post_id = $_GET[post_id];
  6. $query = “SELECT * FROM wp_posts WHERE ID = $post_id AND post_status = ‘publish’”;
  7. $result = mysql_query($query) or die(mysql_error());
  8. $xml_output = “<?xml version=\”1.0\” encoding=\”utf-8\”?>\n”;
  9. $xml_output .= “<entries>\n”;
  10. for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
  11. $row = mysql_fetch_assoc($resultID);
  12. $xml_output .= “\t<entry>\n”;
  13. $xml_output .= “\t\t<posttitle>” . $row['post_title'] . “</posttitle>\n”;
  14. $xml_output .= “\t\t<postdate>” . $row['post_date'] . “</postdate>\n”;
  15. $xml_output .= “\t\t<postcopy><![CDATA[ <p>" . $row['post_content'] . “</p>]]></postcopy>\n”;
  16. $xml_output .= “\t\t<postlink>test</postlink>\n”;
  17. $xml_output .= “\t</entry>\n”;
  18. }
  19. $xml_output .= “</entries>”;
  20. echo $xml_output;
  21. ?>

Now, I’m in a dilemma. What else should I do to be able to connect to the database without accessing the wp-config.php file?


Comments


blog comments powered by Disqus


Popular Posts