Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Broken RSS feed echoed from php

    This is my php code.
    PHP Code:
    <?php 
    echo '<?xml version="1.0"?>';
    echo 
    '<rss version="2.0">';
    echo 
    "<channel>";
    echo 
    "<title> J10 Presents: The Sleeper </title>";
    echo 
    "<link>www.j10thesleeper.net84.net/j10sleeperhomepage.html</link>";
    echo 
    "<description> This is a description for you to decide on, Justin.</description>";
    $x=0;
    $connect mysqli_connect('host','user','password','database');
    $rssaudiopath mysqli_query($connect,"select * from the_sleeper");
    $numRows=mysql_num_rows($rssaudiopath);
    Do
    {
    $rssaudio=mysqli_query($connect,"select * from the_sleeper where id=$x") or die(mysqli_error());
    $rssrow=mysqli_fetch_array($rssaudio);
    echo 
    "<item>";
    echo 
    "<title>"$rssrow['title'] . "</title> <link>" $rssrow['audiopath'] . "</link> <description>" $rssrow['description'] ."</description>";
    echo 
    "</item>";
    $x++;}
    while (
    $x<=$numRows);
    echo 
    "</channel>";
    echo 
    "</rss>";
    mysqli_close($connect);
    ?>
    This is the output I get.
    http://www.j10thesleeper.net84.net/RSSfeed.php

    I am trying to access the table the_sleeper in my mysql database so that it will post each of the items in the mysql database as a seperate item in the RSS feed. None of the items show up. What is wrong with my code?

    Thank you for your time!
    Last edited by torsaur; 03-21-2013 at 01:29 AM. Reason: Noticed extra title tags. Not resolved.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Check the HTML source of that page for
    Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource in <b>/home/a2379928/public_html/RSSfeed.php</b> on line <b>11</b><br />
    Change
    Code:
    $rssaudiopath = mysqli_query($connect,"select * from the_sleeper");
    to
    PHP Code:
    $rssaudiopath mysqli_query($connect,"select * from the_sleeper") or die(mysqli_error()); 
    and see what happens
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I changed the code and no error appeared. The output stayed the same.

  • #4
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    try

    PHP Code:

     <?php 
    echo '<?xml version="1.0"?>';
    echo 
    '<rss version="2.0">';
    echo 
    "<channel>";
    echo 
    "<title> J10 Presents: The Sleeper </title>";
    echo 
    "<link>www.j10thesleeper.net84.net/j10sleeperhomepage.html</link>";
    echo 
    "<description> This is a description for you to decide on, Justin.</description>";

    $connect mysqli_connect('host','user','password','database');
    $rssaudio=mysqli_query($connect,"select * from the_sleeper") or die(mysqli_error());
    mysqli_close($connect);
    while (
    $rssrow=mysqli_fetch_array($rssaudio)){
    echo 
    "<item>";
    echo 
    "<title>";
    echo 
    "<title>"$rssrow['title'] . "</title> <link>" $rssrow['audiopath'] . "</link> <description>" $rssrow['description'] ."</description>";
    echo 
    "</title>";
    echo 
    "</item>";
    }

    echo 
    "</channel>";
    echo 
    "</rss>";

     
    ?>
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • Users who have thanked Arcticwarrio for this post:

    torsaur (03-23-2013)

  • #5
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I changed the code to that and it didn't work. It got some of the content from the table, but the rss feed completely dissapeared.

  • #6
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    What did it get and what disappeared?
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #7
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    just realised you have 2 titles in this:


    Quote Originally Posted by Arcticwarrio View Post
    try

    PHP Code:

     <?php 
    echo '<?xml version="1.0"?>';
    echo 
    '<rss version="2.0">';
    echo 
    "<channel>";
    echo 
    "<title> J10 Presents: The Sleeper </title>";
    echo 
    "<link>www.j10thesleeper.net84.net/j10sleeperhomepage.html</link>";
    echo 
    "<description> This is a description for you to decide on, Justin.</description>";

    $connect mysqli_connect('host','user','password','database');
    $rssaudio=mysqli_query($connect,"select * from the_sleeper") or die(mysqli_error());
    mysqli_close($connect);
    while (
    $rssrow=mysqli_fetch_array($rssaudio)){
    echo 
    "<item>";
    echo 
    "<title>";
    echo 
    "<title>"$rssrow['title'] . "</title> <link>" $rssrow['audiopath'] . "</link> <description>" $rssrow['description'] ."</description>";
    echo 
    "</title>";
    echo 
    "</item>";
    }

    echo 
    "</channel>";
    echo 
    "</rss>";

     
    ?>
    please try:

    [PHP]

    PHP Code:

     <?php 
    echo '<?xml version="1.0"?>';
    echo 
    '<rss version="2.0">';
    echo 
    "<channel>";
    echo 
    "<title> J10 Presents: The Sleeper </title>";
    echo 
    "<link>www.j10thesleeper.net84.net/j10sleeperhomepage.html</link>";
    echo 
    "<description> This is a description for you to decide on, Justin.</description>";

    $connect mysqli_connect('host','user','password','database');
    $rssaudio=mysqli_query($connect,"select * from the_sleeper") or die(mysqli_error());
    mysqli_close($connect);
    while (
    $rssrow=mysqli_fetch_array($rssaudio)){
    echo 
    "<item>";
    echo 
    "<title>"$rssrow['title'] . "</title> <link>" $rssrow['audiopath'] . "</link> <description>" $rssrow['description'] ."</description>";
    echo 
    "</item>";
    }

    echo 
    "</channel>";
    echo 
    "</rss>";

     
    ?>
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #8
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I realized that and a few other small errors and edited them out a bit ago. It didn't solve the issue though. It seems like a real mystery... I just can't comprehend why it's not working in the way it should. The issue seems to be the error abdura pointed out earlier.

  • #9
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,259
    Thanks
    10
    Thanked 276 Times in 275 Posts
    Are you sure your connect (mysqli_connect) is even working?

    Dave

  • #10
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yes, I use the same connection statement of the homepage.

  • #11
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I finally found out the error.
    I was using the mysql_num_rows function, which is not compatible with mysqli result resources. I simply changed it to mysqli_num_rows, and the problem was solved. Thank you all for your help!

  • #12
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    post your new code, i'd like to see if theres anything else we can do to it
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #13
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php 
    echo '<?xml version="1.0"?>';
    echo 
    '<rss version="2.0">';
    echo 
    "<channel>";
    echo 
    "<title> J10 Presents: The Sleeper </title>";
    echo 
    "<link>www.j10thesleeper.net84.net/j10sleeperhomepage.html</link>";
    echo 
    "<description> This is a description for you to decide on, Justin.</description>";
    $x=-1;
    $connect mysqli_connect('mysql3.***************','a2379928_Torsaur','hihihi111','a2379928_Sleeper');
    $rssaudiopath mysqli_query($connect,"select * from the_sleeper");
    mysqli_fetch_array($rssaudiopath);
    $numRows=mysqli_num_rows($rssaudiopath);
    while (
    $x<=$numRows)
    {
    $rssaudio=mysqli_query($connect,"select * from the_sleeper where id='$x'");
    $rssrow=mysqli_fetch_array($rssaudio);
    echo 
    "<item>";
    echo 
    "<title>"$rssrow['title'] . "</title> <link>" $rssrow['audiopath'] . "</link> <description>" $rssrow['description'] ."</description>";
    echo 
    "</item>";
    $x++;
    }
    echo 
    "</channel>";
    echo 
    "</rss>";
    mysqli_close($connect);
    ?>

  • #14
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    PHP Code:
    $x=-1;
    $connect mysqli_connect('mysql3.***************','a2379928_Torsaur','hihihi111','a2379928_Sleeper');
    $rssaudiopath mysqli_query($connect,"select * from the_sleeper");
    mysqli_fetch_array($rssaudiopath);
    $numRows=mysqli_num_rows($rssaudiopath);
    while (
    $x<=$numRows)
    {
    $rssaudio=mysqli_query($connect,"select * from the_sleeper where id='$x'");
    $rssrow=mysqli_fetch_array($rssaudio); 
    is the same as

    PHP Code:
    $connect mysqli_connect('mysql3.***************','a2379928_Torsaur','hihihi111','a2379928_Sleeper');
    $rssaudiopath mysqli_query($connect,"select * from the_sleeper");
    mysqli_fetch_array($rssaudiopath);
    mysqli_close($connect); 
    while (
    $rssrow=mysqli_fetch_array($rssaudiopath){ 
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #15
    New Coder
    Join Date
    Mar 2013
    Location
    Kentucky
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I don't understand how. Wouldn't that create an infinite loop since $rssrow will always equal itself? Also, how would that loop through the specific rows to post each? Thank you!


  •  

    Tags for this Thread

    Posting Permissions

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