Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default RSS php code

    Can anyone see what is wrong with the attached code. I have a table named
    'page' with the field 'Number' 'Title' and 'ImageLink' within it. I can get
    the simple rss feed to show up with my website information but it wont echo the
    items within the database.

    <?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>MyWebsite Blog Headlines</title>
    <description>New Blog Entries</description>
    <link>http://www.mywebsite.com/</link>
    <image>
    <title>mywebsite</title>
    <width>142</width>
    <height>18</height>
    <link>http://www.mywebsite.com</link>
    <url>http://www.mywebsite.com/Images/smallbanner</url>
    </image>';
    require_once('Connections/MyConnection.php');
    // Query database and select the last 10 entries.
    $data = mysql_query('SELECT * FROM page ORDER BY Number DESC LIMIT 10');
    while($row = mysql_fetch_array($data))
    {
    // Convert database images data into actual image link.
    $row[ImageLink] = str_replace('images/', 'http://www.mywebsite.com/images/',
    $row[ImageLink]);
    // Continue with the 10 items to be included in the <item> section of the XML.
    echo '
    <item>
    <link>http://www.mywebsite.com/detailed.php?recordID='.$row[Number].'</link>
    <guid
    isPermaLink=\?true\?>http://www.mywebsite.com/detailed.php?recordID='.$row[Numbe
    r].'</guid>
    <title>'.$row[Title].'</title>
    <description><![CDATA['.$row[ImageLink].']]></description>

    <comments>http://www.mywebsite.com/detailed.php?recordID='.$row[Entry].'#Comment
    s</comments>
    </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>';
    ?>

    jh369057 Guest

  2. Similar Questions and Discussions

    1. Why doesn't the Code Completion occur in FlexBuilder IDEwhen source code is in an external file?
      I am seperating my .as from the MXML by using the following in my file.mxml: <mx:Script source="file.as"> When I edit file.as, the code...
    2. How would I include the Open Browser code into this lineof code?
      Hello and thankyou in advance: I have an ASP page linked to my database and I want to apply the Open Browser behaviour to the code. I have tried...
    3. Custom control fires event but ignores some code in the code behind file
      I do not quite understand the question. I will merely point out that most programming problems happen for a reason. Code works the way it is...
    4. Custom tool warning: DiscoCodeGenerator unable to initialize code generator. No code generated.
      I created a brand new WebService (HelloWorld) and when I attempt to add this WebService to a WindowsForm project I get the following error message in...
    5. Security problem with Managed Code calling Unmanaged Code in a Web Page
      Hello, I have a web page which contains an ActiveX control (unmanaged) and a Windows Forms User Control (managed). Both reside on a web page and...
  3. #2

    Default Re: RSS php code

    jh369057 wrote:
    > Can anyone see what is wrong with the attached code. I have a table named
    > 'page' with the field 'Number' 'Title' and 'ImageLink' within it. I can get
    > the simple rss feed to show up with my website information but it wont echo the
    > items within the database.
    If your code does not output the content from the database, then either you are attempting to output it improperly, or the data is not getting accessed from the database properly and isn't present to output.

    In a quick look, there are several potential problems:
    Your mysql_query doesn't specify the database connection, it's possible that your connection include specifies it, but as you didn't show the code it's hard to tell.

    When you output the values for from your row of data, you do not have them quoted, as in:
    $row[Number]
    It should be something like:
    $row["Number"]

    If that doesn't help, or you still have problems, you should ask your question over in the Dreamweaver Application Dev group:
    [url]http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=12&catid=263&entercat=y[/url]
    And post a link to your page, as it may help in determining what is getting output and what should be output. Also, if you are getting any errors, you should post what those errors are and on which lines. When working with XML files, it may be harder to determine if there is an error, especially with RSS XML, as some browsers may be hiding the errors generated. It may be good to comment out the content type header, and only uncomment it when you have a fully working page.


    --
    Danilo Celic
    | [url]http://blog.extensioneering.com/[/url]
    | WebAssist Extensioneer
    | Adobe Community Expert
    danilocelic AdobeCommunityExpert Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139