Jump to content

[SOLVED] ALMOST WORKING...my rss IF die problem...


shane85

Recommended Posts

sorry guys last time im gonna be posting this I hope....so as ive said previously, im creating an rss file that software is pointing to read....I want to do an IF statement that if $row->ticker is empty, die and do not load the rss page...where as if there is txt, load the page...right now I have it so that if there is text, the page loads...however if there is no txt, I get a "feed code error" if I take out the rss in the coding and leave it blank, then the if statement works and says "Ticker is empty or not set" and dies....why am I getting feed code error when the ticker is empty and its not exiting??? the code is as follows

 

// make a connection to mysql here
$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ($dbname) or die ("I cannot select the database '$dbname' because: " . mysql_error());

$result = mysql_query("SELECT location_id, ticker FROM host_locations WHERE location_id='2' AND ticker IS NOT NULL")or die(mysql_error()); 

while ($row = mysql_fetch_object($result)) { // begin while statement

if (empty($row->ticker)){
die("Ticker is empty or not set"); //Displays an error and kill page.
} else { // begin to display the rss for the if statement

         //echo "$row->ticker"; // show the $row->ticker to make sure its working

header('Content-type: application/xml');

echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
echo "<channel>\n";

echo "<title>RSS Feed</title>\n";

//while ($row = mysql_fetch_object($result)) {

         echo "<item>\n";
         echo "<title>$row->ticker</title>\n";
         echo "</item>\n";
//}

echo "</channel>\n";

echo "</rss>\n";



} // end the if statement for ticker
} // end WHILE statement

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.