Jump to content

Strange error messages, help me please?


scotty99

Recommended Posts

Within my website I have an RSS feed which the news page uses to display up to date news. What I want is for a form to be placed in the restricted area so members of staff can add to the RSS feed without any technical knowledge. The RSS feed is located here. The news page is here.

Here is the code which I was given:

<?php
// Local location of newsfeed file
$feed_file = "http://www.crieffaircadets.org.uk/newsfeed.xml";

// Some Channel Variables - Editable
$channel_title = "38 (Crieff) DF - News Channel";
$channel_description = "Keep up to date with the latest news about the flight.";
$channel_link = "http://www.crieffaircadets.org.uk/newsfeed.xml";

// Array to hold feed items - do not edit
$channel_items = array();

// Placeholder for error messages - do not edit
$message = "";
$message_class = "";

// If the form submit button (btnSubmit) was pressed
if(isset($_POST['btnSubmit']))
{
   // Values from the form
   $title = trim($_POST['txtTitle']);
   $desc = trim($_POST['txtDesc']);
   
   // If both fields were not empty
   if(!empty($title) && !empty($desc))
   {
      // If magic quotes are enabled on your server, counter it 
      if(get_magic_quotes_gpc())
      {
         $title = stripslashes($title);
         $desc = stripslashes($desc);      
      }
   
      // Get the current RSS Feed
      $xml = new SimpleXMLElement($feed_file, null, true);

      // Add the new item to the channel_items array
      $channel_items[] = array(
            "title" => $title,
            "description" => $desc,
            "link" => "http://www.crieffaircadets.org.uk/news.php#start",
            "guid" => date("Y-M-d-H-i-s-") . rand(0,100),
            "pubDate" => date("D, d M Y H:i:s") . " +0000"         
      );
               
      // Read the current items within the feed and add them to the channel_items array
      foreach($xml->channel->item as $item)
      {
         $channel_items[] = array(
            "title" => $item->title,
            "description" => $item->description,
            "link" => $item->link,
            "guid" => $item->guid,
            "pubDate" => $item->pubDate
         );      
      }
               
      // Rewrite the XML RSS file
      if($new_file = fopen($feed_file, "w"))
      {
         // Channel tags
         $rss = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
         $rss .= "<rss version=\"2.0\">\r\n";
         $rss .= "  <channel>\r\n";
         $rss .= "    <title>" . $settings['site_name'] . "</title>\r\n";
         $rss .= "    <description>" . $settings['site_desc'] . "</description>\r\n";
         $rss .= "    <link>" . $settings['site_url'] . "</link>\r\n";
         $rss .= "    <lastBuildDate>" . date("D, d M Y H:i:s") . " +0000</lastBuildDate>\r\n";
         
         // Item tags
         foreach($channel_items as $item)
         {
            $rss .= "    <item>\r\n";
            $rss .= "      <title>" . $item['title']. "</title>\r\n";
            $rss .= "      <description>" . $item['description'] . "</description>\r\n";
            $rss .= "      <link>" . $item['link'] . "</link>\r\n";
            $rss .= "      <guid isPermaLink=\"false\">" . $item['guid'] . "</guid>\r\n";
            $rss .= "      <pubDate>" . $item['pubDate'] . " +0000</pubDate>\r\n";
            $rss .= "    </item>\r\n";               
         }
         
         $rss .= "  </channel>\r\n";
         $rss .= "</rss>";
         
         // Physically write the content to the feed file
         fwrite($new_file, $rss);
         fclose($new_file);
         
         $message_class = "message-good";
         $message = "The news item was added successfully.";
         
         // Reset the form field values
         $title = "";
         $desc = "";
      }
      else
      {
         $message_class = "message-bad";
         $message = "Could not write to XML file. Check you have write permissions on this file.";            
      }
   }
   else
   {
      $message_class = "message-bad";
      $message = "Not all of the form fields were completed.";
   }
}
else
{
   // Else use default values
   $title = "";
   $desc = "";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="38 (Crieff) DF Activities" />
<meta name="keywords" content="38, crieff, ATC, air cadets" />
<meta name="author" content="David Bendall" />
<link rel="stylesheet" type="text/css" href="/main.css" media="screen,projection" title="andreas02 (screen)" />
<link rel="stylesheet" type="text/css" href="/print.css" media="print" />
    <title>38 (Crieff) DF - Update RSS Feed</title>
    <style type="text/css">
   .message-good {
      background-color: #009900;
      border-top: 1px solid #003300;
      border-bottom: 1px solid #003300;
      margin-bottom: 4px;
      padding: 4px;      
   }
   
   .message-bad {
      background-color: #FF6633;
      border-top: 1px solid #990000;
      border-bottom: 1px solid #990000;
      margin-bottom: 4px;
      padding: 4px;   
   }
   </style>
</head>

<body>
<div id="toptabs">
<p>Quick Links: 
<a class="toptab" href="http://www.aircadets.org/">HQAC</a><span class="hide"> | </span>
<a class="toptab" href="http://aircadets-sni.org.uk/recruit.php">S&NI Region</a><span class="hide"> | </span>
<a class="toptab" href="http://www.hqdcswatc.org.uk/">DCS Wing</a><span class="hide"> | </span>
<a class="toptab" href="http://www.38f.co.uk">38F</a><span class="hide"> | </span></p>
</div>

<div id="container">
<div id="logo">
<h1>Staff</h1>
</div>

<div id="navitabs">
<h2 class="hide">Site menu:</h2>
<a class="navitab" href="/index.php">Home</a><span class="hide"> | </span>
<a class="navitab" href="/restricted/index.html">Cadets</a><span class="hide"> | </span>
<a class="navitab" href="/restricted/restricted-2/staffhome.html">Staff Home</a><span class="hide"> | </span>
<a class="activenavitab" href="/restricted/restricted-2/addnews/addnews.php5">Add News</a><span class="hide"> | </span>
<a class="navitab" href="/restricted/restricted-2/massmessage/index.html">Mass Message</a><span class="hide"> | </span>
<a class="navitab" href="/restricted/restricted-2/contacts/index.html">Contacts</a>
</div>



<div id="desc">
<h2>Update News Feed</h2>
<p>Use this page to add an item to the news feed. </p>

</div>

<div id="main">

<?php
// If there's a message then display it
if(!empty($message))
{
   echo "<div class=\"" . $message_class . "\">" . $message . "</div>";
}
?>

<form method="post" action="<?=$_SERVER['file:///C|/Documents and Settings/David Bendall/My Documents/PHP_SELF']?>">

<p><label for="txtTitle">Title:</label>
  <input type="text" id="txtTitle" name="txtTitle" value="<?=$title?>"/>
</p>
<p><label for="txtDesc">Description:</label><br /><textarea id="txtDesc" name="txtDesc" style="width:250px;height:100px;"><?=$desc?></textarea></p>

<p><input type="submit" id="btnSubmit" name="btnSubmit" value="Submit News Item" /></p>

</form>
</div>


<div id="footer">
Log in to <a href="/restricted/index.html">Cadets »</a> | <a href="/restricted/restricted-2/staffhome.html">Staff »</a>
<br />
© 38 (Crieff) DF Air Training Corps
<br />
Comments? Suggestions? Contact the <a href="../../webmaster/index.html">Webmaster</a>
<br />
<a href="/info/privacy.html">Privacy Policy & Disclaimer</a> | <a href="/info/sitemap.html">Site Map</a></div>

</div>
</body>
</html>

 

But upon clicking submit, it returns this:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: URL file-access is disabled in the server configuration in /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5 on line 35

Warning: SimpleXMLElement::__construct(http://www.crieffaircadets.org.uk/newsfeed.xml) [simplexmlelement.--construct]: failed to open stream: no suitable wrapper could be found in /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5 on line 35

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: I/O warning : failed to load external entity "http://www.crieffaircadets.org.uk/newsfeed.xml" in /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5 on line 35

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5:35 Stack trace: #0 /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5(35): SimpleXMLElement->__construct('http://www.crie...', 0, true) #1 {main} thrown in /homepages/20/d214972145/htdocs/restricted/restricted-2/addnews/addnews.php5 on line 35

 

Can anyone help me please?

Link to comment
https://forums.phpfreaks.com/topic/120998-strange-error-messages-help-me-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.