Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: XML Mysql Php

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default XML Mysql Php

    I am trying to create a feed of my website, using my mysql database. I have found many tutorials on these but i cant seem to get any of them working, i keep getting the same error.
    Code:
    Safari can’t open the page.
    Safari can’t open the page “feed://mypage.net/feed.xml”. The error is: “The feed could not be loaded because the content is not in a known feed format.” (PubSub:2) Please choose Safari > Report Bugs to Apple, note the error number, and describe what you did before you saw this message.
    I am trying to use the tutorial found here.
    http://www.webwicked.com.au/download...QL_RSSFeed.pdf

    any help is appreciated, thanks.

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Can you link to the running application? A copy of the (censored) PHP source would be good as well.

    I'm particularly interested in looking at your XML output, as that seems to be where the problem lies.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Here is the code
    Code:
    <?php 
    header(“Content-type: text/xml”); 
    echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>”; 
    // Set RSS version. 
    echo “ 
    <rss version=\”2.0\”> “; 
    // Start the XML. 
    echo “ 
      <channel> 
        <title>Feed title</title> 
        <description>A description of the feed contents</description> 
        <link>http://www.yoursite.com/</link>”; 
       
       
       mysql_connect("","","");
    	
    mysql_select_db(""); 
    
    
        // Query database and select the last 10 entries. 
        $data = mysql_query(“SELECT * FROM hmr ORDER BY id DESC LIMIT 10”); 
        while($row = mysql_fetch_array($data)) 
        { 
            // Continue with the 10 items to be included in the <item> section of the XML. 
        echo “ 
        <item> 
          <link>http://www.yoursite.com/article.php?id=”.$row[id].”</link> 
          <guid isPermaLink=\”true\”>http://www.yoursite.com/article.php?id=”.$row[id].”</guid> 
          <title>Title Here</title> 
          <description><![CDATA[“.$row[entrytext].”]]></description> 
            <comments>http://www.yoursite.com/article.1
    		
    		</item>”; 
    } 
    // substr can limit the number of characters. First number is starting point while the second number is number of 
    characters. 
    // otherwise just use $row[Intro]. 
    // <guid> is an optional sub-element of <item> but recommended if you don’t want to receive a warning when 
    validating your RSS. 
     
    echo “ 
      </channel> 
    </rss>”; 
    ?>
    And it can be found here..
    feed://roomwatch.uuuq.com/feed.xml

  4. #4
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Your server isn't recognizing your PHP as needing to be parsed, so the browser is receiving the PHP instead of its output. EDIT: I discovered this by viewing the file's source, just like with an HTML page.

    There are two ways to make it work. If you want to parse PHP in all .xml files within a certain directory, you can configure this on your server; Apache uses the AddHandler directive for this.

    If you want to make this work on a per-file basis instead (or you can't/don't want to mess with the server's configuration), just rename the file with a .php extension (feed.php or feed.xml.php). Your content-type header will inform the browser about what the output is.

    I read somewhere that some browsers will choke on the space after the colon, but I can't find anything to cite for that.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  5. #5
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Still no luck
    seen here : feed://roomwatch.uuuq.com/feed.xml.php

    i also tried changing the extension to just .php, same error.

    I'm actually using bluehost as a webhost this is just my test area.
    Does anyone know if bluehost has some special way to do what im attempting too?

    Thanks

  6. #6
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Nope, this is a different error - maybe not when Safari interprets it as XML, though. Try visiting the actual feed.
    Quote Originally Posted by http://roomwatch.uuuq.com/feed.xml.php
    Parse error: syntax error, unexpected ':' in /www/uuuq.com/r/o/o/roomwatch/htdocs/feed.xml.php on line 2
    Line 2 in your previously posted source is:
    Code:
    header(“Content-type: text/xml”);
    I don't see where the error is coming from, unless... Try exchanging those quotes for copies of this one: "
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  7. #7
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Haha tried changing the " around. Still no luck with anything in particular. I figured this would be simpler then it is turning out to be. Are there any options available to me?

  8. #8
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    What are you editing in? I know those quotes look different, and that's the only way a syntax error could be found inside a string, especially that early in the code...

    EDIT: I just verified this as the problem by running your code on my localhost.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  9. The Following User Says Thank You to Jesdisciple For This Useful Post:

    SChaput (07-11-2009)

  10. #9
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    You used the exact code i posted above and it worked fine? Very strange. I did notice as you stated earlier, the " were an odd sort of ". After changing that i still had no luck.

    When you got it to work did you save as a .php or .xml

  11. #10
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Finally got it figured it out.

    feed://ihatemyroommate.net/feed.php

    I used a different tutorial, seemed even more basic and used your advice on the .php extension. I was under the impression an RSS feed needed to be .xml

    Thanks alot for your help!

Bookmarks

Posting Permissions

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