Jump to content

pouncer

Members
  • Posts

    324
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pouncer's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. The html form is built dynamically. <form method ='post' action='index.php' name='rss_record'> <input name='txtRSS_15' type='text' id='txtRSS' size='70' value='http://slashdot.org/rss/slashdot.rss'/> <input name='update' type='submit' value='Update'/> <input name='delete' type='submit' value='Delete'/> <input name='view_rss' type='submit' value='View'/> <input type='hidden' name='rss_id' value='15'> </form>
  2. for e.g whats the difference between @mysql_insert and mysql_insert and for e.g if (!$rss_data = @file_get_contents($link)) { echo "Sorry, no RSS feed was found at <b>$link</b>"; } when i removed the @ from t@file_get_contents the page threw an error. but when i remove the @ from mysql_insert - no error?
  3. if (isset($_POST['update'])) { $rss_id = $_POST['rss_id']; $link = $_POST["txtRSS_" . $rss_id]; updateLink($rss_table, $rss_id, $link); } elseif (isset($_POST['delete'])) { $rss_id = $_POST['rss_id']; deleteLink($rss_table, $rss_id); } elseif (isset($_POST['view_rss'])) { $rss_id = $_POST['rss_id']; $link = $_POST["txtRSS_" . $rss_id]; viewRSS($link); } It's just if statements, but the contents of some of them are the same like the $rss_id variables.
  4. just trying to make the code smaller i guess
  5. /* * Check if an RSS Feed link already exists in the database. */ function rssExists($link, $rss_table) { $check_link = mysql_query("SELECT * FROM `$rss_table` where rsslink='$link'") or die("Query error: <b>". mysql_error()); $rows = mysql_num_rows($check_link); if ($rows == 1) return true; else return false; } Is it possible to do it without using a query?
  6. I've got this code at the to of my index.php <? require_once("database.php"); require_once("functions.php"); $db = new Database(); $db->Connect(); ?> The Connect() method is just the mysql_connect(...) stuff. So everytime I refresh my index.php, is my web app always executing the mysql_connect?? is there a better way to do it so it just connects once when i open the index.php and not again and again...
  7. As part of form validation, i want to throw a msgbox, instead of something like echo "blah blah" i dont want to use javascript incase clientsides have javascript disabled?
  8. I currently use PHP to do this: $rsslink = $_POST['txtRSS']; if ($rsslink == "") echo "<b>You didn't specify any link to add.</b>"; But I want to replace it with javascript and throw a msgbox onto the screen instead. Any ideas anyone?
  9. foreach ($rss_xml->channel->item as $item) { $item_title = $item->title; $item_link = $item->link; $item_description = $item->description; echo " <h3><a href='$item_link'>$item_title</a></h3> <p>$item_description</p> <p><a href='$item_link'>Continue reading $item_title</a></p> \n"; } foreach ($rss_xml->item as $item) { $item_title = $item->title; $item_link = $item->link; $item_description = $item->description; echo " <h3><a href='$item_link'>$item_title</a></h3> <p>$item_description</p> <p><a href='$item_link'>Continue reading $item_title</a></p> \n"; } the only thing that is different is the 'foreach' lines foreach ($rss_xml->channel->item as $item) foreach ($rss_xml->item as $item) but the stuff inside it is the same. so is there a way to cut down the amount of duplicated code?
  10. Brian I hope you can help me, the code you posted now works fine for: http://www.php.net/news.rss but i also want it to work for the likes of http://www.shanedj.com/blog/feed/rss/ too
  11. hmmm i see!! is there a way to make it work for all kinds of rss then? or will the code you posted do that now?
  12. view_rss.php <? $rss_url = "http://www.php.net/news.rss"; if (!$rss_data = @file_get_contents($rss_url)) { echo "<p>No RSS found at $rss_url</p><p>Hmmm thats not meant to happen. RSS Fail!</p>"; } else { $rss_xml = SimpleXML_Load_String($rss_data); $channel_title = $rss_xml->channel->title; $channel_link = $rss_xml->channel->link; foreach ($rss_xml->channel->item as $item) { $item_title = $item->title; $item_link = $item->link; $item_description = $item->description; echo "<h3><a href=\"$item_link\">$item_title</a></h3><p>$item_description</p><p class=\"text_right\"><a href=\"$item_link\">Continue reading $item_title</a></p>\n"; } } ?> Doesn't seem to display nothing for me. but when i try another rss link like $rss_url = "http://www.shanedj.com/blog/feed/rss/"; then it works fine, any ideas whats going wrong guys?
  13. echo " <table border=0> <tr><th bgcolor=#E1E4F2>RSS Feeds getTotalLinks($rss_table)</th></tr> "; how can i make it execute the getTotalLinks($rss_table) function within echo "..." without closing the php tags?
×
×
  • 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.