shane85 Posted August 18, 2009 Share Posted August 18, 2009 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 https://forums.phpfreaks.com/topic/170794-solved-almost-workingmy-rss-if-die-problem/ Share on other sites More sharing options...
shane85 Posted August 18, 2009 Author Share Posted August 18, 2009 where it says feed code error there is a button I can push for more info...I did and it says Invalid at the top level of the document. Line: 1 Character: 1 Ticker is empty or not set Link to comment https://forums.phpfreaks.com/topic/170794-solved-almost-workingmy-rss-if-die-problem/#findComment-900742 Share on other sites More sharing options...
shane85 Posted August 18, 2009 Author Share Posted August 18, 2009 bump Link to comment https://forums.phpfreaks.com/topic/170794-solved-almost-workingmy-rss-if-die-problem/#findComment-900924 Share on other sites More sharing options...
daveoffy Posted August 18, 2009 Share Posted August 18, 2009 Add me on aim/msn/gtalk. daveoffy/[email protected]/d.offy12 Will post answer here once solved. Link to comment https://forums.phpfreaks.com/topic/170794-solved-almost-workingmy-rss-if-die-problem/#findComment-900936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.