Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-20-2013, 03:05 AM
PM User |
#1
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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.
03-20-2013, 08:23 AM
PM User |
#2
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
Check the HTML source of that page for
Quote:
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
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
03-20-2013, 08:06 PM
PM User |
#3
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
I changed the code and no error appeared. The output stayed the same.
03-20-2013, 08:53 PM
PM User |
#4
Regular Coder
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 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.
Users who have thanked Arcticwarrio for this post:
03-21-2013, 08:58 PM
PM User |
#5
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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.
03-21-2013, 09:04 PM
PM User |
#6
Regular Coder
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
What did it get and what disappeared?
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
03-21-2013, 09:06 PM
PM User |
#7
Regular Coder
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
just realised you have 2 titles in this:
Quote:
Originally Posted by
Arcticwarrio
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.
03-22-2013, 03:16 AM
PM User |
#8
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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.
03-22-2013, 04:07 AM
PM User |
#9
Regular Coder
Join Date: Aug 2006
Posts: 891
Thanks: 4
Thanked 205 Times in 204 Posts
Are you sure your connect (mysqli_connect) is even working?
Dave
03-22-2013, 08:18 PM
PM User |
#10
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Yes, I use the same connection statement of the homepage.
03-22-2013, 08:49 PM
PM User |
#11
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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!
03-22-2013, 10:07 PM
PM User |
#12
Regular Coder
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 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.
03-22-2013, 10:46 PM
PM User |
#13
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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 );
?>
03-23-2013, 03:02 AM
PM User |
#14
Regular Coder
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 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.
03-23-2013, 03:08 PM
PM User |
#15
New Coder
Join Date: Mar 2013
Location: Kentucky
Posts: 14
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!
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 07:12 AM .
Advertisement
Log in to turn off these ads.