Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2013, 03:05 AM   PM User | #1
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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.
torsaur is offline   Reply With Quote
Old 03-20-2013, 08:23 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
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)
abduraooft is offline   Reply With Quote
Old 03-20-2013, 08:06 PM   PM User | #3
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
I changed the code and no error appeared. The output stayed the same.
torsaur is offline   Reply With Quote
Old 03-20-2013, 08:53 PM   PM User | #4
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
Arcticwarrio is on a distinguished road
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.
Arcticwarrio is offline   Reply With Quote
Users who have thanked Arcticwarrio for this post:
torsaur (03-23-2013)
Old 03-21-2013, 08:58 PM   PM User | #5
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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.
torsaur is offline   Reply With Quote
Old 03-21-2013, 09:04 PM   PM User | #6
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
Arcticwarrio is on a distinguished road
What did it get and what disappeared?
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 03-21-2013, 09:06 PM   PM User | #7
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
Arcticwarrio is on a distinguished road
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.
Arcticwarrio is offline   Reply With Quote
Old 03-22-2013, 03:16 AM   PM User | #8
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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.
torsaur is offline   Reply With Quote
Old 03-22-2013, 04:07 AM   PM User | #9
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 891
Thanks: 4
Thanked 205 Times in 204 Posts
tracknut is an unknown quantity at this point
Are you sure your connect (mysqli_connect) is even working?

Dave
tracknut is offline   Reply With Quote
Old 03-22-2013, 08:18 PM   PM User | #10
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
Yes, I use the same connection statement of the homepage.
torsaur is offline   Reply With Quote
Old 03-22-2013, 08:49 PM   PM User | #11
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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!
torsaur is offline   Reply With Quote
Old 03-22-2013, 10:07 PM   PM User | #12
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
Arcticwarrio is on a distinguished road
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.
Arcticwarrio is offline   Reply With Quote
Old 03-22-2013, 10:46 PM   PM User | #13
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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);
?>
torsaur is offline   Reply With Quote
Old 03-23-2013, 03:02 AM   PM User | #14
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 581
Thanks: 15
Thanked 65 Times in 65 Posts
Arcticwarrio is on a distinguished road
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.
Arcticwarrio is offline   Reply With Quote
Old 03-23-2013, 03:08 PM   PM User | #15
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
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!
torsaur is offline   Reply With Quote
Reply

Bookmarks

Tags
mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:12 AM.


Advertisement
Log in to turn off these ads.