Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Includes Error Message

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Includes Error Message

Postby orendon » Fri Mar 15, 2013 3:03 pm

I have a problem and all search results suggestions do not word.
My site has some 400 pages and all the article pages have this code that causes an error.
The site is running on Godaddy's lenux server.

To see the error go to my web site is http://www.weddingsandweddingplanning.com select "Enter" and look at the bottom of the page and also from there select an article and see the same error at the bottom...

All the other includes in the"Includes" folder work fine including Adsense, Amazon and others, except this one....

This is the code that's near the bottom of all the articles page coding....

<tr>
<td colspan="3">
<?php include("$Domain/Includes/NewsFeed.php?CAT=$NewsFeed"); ?>
</td>
</tr>

This is the error message appears at the bottom of all articles. See below for the include file content of NewsFeed.php..

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/content/o/r/e/orendon/html/weddingsandweddingplanning/Articles/Free_Wedding_Vows.php on line 70

Warning: include(http://weddingsandweddingplanning.com// ... T=Weddings) [function.include]: failed to open stream: no suitable wrapper could be found in /home/content/o/r/e/orendon/html/weddingsandweddingplanning/Articles/Free_Wedding_Vows.php on line 70

Warning: include() [function.include]: Failed opening 'http://weddingsandweddingplanning.com//Includes/NewsFeed.php?CAT=Weddings' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/o/r/e/orendon/html/weddingsandweddingplanning/Articles/Free_Wedding_Vows.php on line 70

This is the include in the Includes folder named NewsFeed, file NewsFeed.php ......

==========================================

<?php

error_reporting(0);

$CAT = $_GET['CAT'];
$CAT = str_replace(" ", "+", $CAT);
$QTY = 10; //$_GET['QTY'];

$url = "http://news.search.yahoo.com/news/rss?p=<keywords>";
$url = str_replace("<keywords>", $CAT, $url);

print "<ul class='ulCategory'>";
flush();

class SimpleXmlParser{

var $SimpleParser;
var $feedUrl;
var $title = "";
var $description = "";
var $link = "";
var $author="";
var $pubDate="";
var $insideitem = false;
var $tag = "";
var $count_results = 0;
var $total_results = 0;

function SimpleXmlParser($MyFeed, $results) {

$this->total_results = $results;
$this->SimpleParser = xml_parser_create();
$this->feedUrl=$MyFeed;

xml_set_object($this->SimpleParser,$this);
xml_set_element_handler($this->SimpleParser, "XmlParserFirstElement", "XmlParserendElement");
xml_set_character_data_handler($this->SimpleParser, "characterData");

$this->ParseFeed(); // Call to Parser Function
}

function XmlParserFirstElement($parser, $tagName, $attrs) {

if ($this->insideitem) {
$this->tag = $tagName;
} elseif ($tagName == "ITEM") {
$this->insideitem = true;
}
}

function XmlParserendElement($parser, $tagName) {
//The Function Will be called, when ever the XML_PARSER Encounters a end Tag, in the XML File
if ($tagName == "ITEM") {

if ($this->count_results < $this->total_results) {

print "<li>";
print " <a target=_new href=\"http://" . $this->link . "\">";
print htmlspecialchars(trim($this->title));
print " </a><br><br>";
print htmlspecialchars(trim($this->description)) . "<br>";
print "</li><br>";

$this->title = "";
$this->description = "";
$this->link = "";
$this->insideitem = false;
}
$this->count_results = $this->count_results + 1;
}
}

function characterData($parser, $data) {

if ($this->insideitem) {
switch ($this->tag) {
case "TITLE":
$this->title .= $data;
break;
case "DESCRIPTION":
$this->description .= $data;
break;

case "LINK":
$this->link .= $data;
$pos = strpos($this->link, "*");
if (!($pos === false)) {
$this->link = substr($this->link , $pos + 1, 300);
}
$this->link = trim($this->link);
$pos = strpos($this->link, "//");
if (!($pos === false)) {
$this->link = substr($this->link , $pos + 2, 300);
}
break;
}
}
}

function ParseFeed(){

$data = file_get_contents($this->feedUrl);
xml_parse($this->SimpleParser, $data);
xml_parser_free($this->SimpleParser);
}
}

$XMLpar = new SimpleXmlParser($url, $QTY);

print "</ul>"

?>
=======================================
Thanx,
orendon
orendon
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Mar 15, 2013 2:07 pm

Re: Includes Error Message

Postby seandisanti » Fri Mar 15, 2013 3:21 pm

It's because you're using url's for your includes instead of relative paths. You can do that (but shouldn't) by modifying your php.ini or using ini_set() to set allow_url_include to 1. it's better to use relative paths, or a getRoot() function that lets you use paths based on your root, regardless of where you're calling from. That's what i typically do. here's a push in that direction...
Code: Select all

/*
 * 
 * function getRoot
 * Parameters:
 *      $uri = string path of the calling file; passed automatically from layout_top.php
 * Returns:
 *      on success: string value to jump from current file to /root/
 *      on fail:    
 */

function getRoot($uri '') {
    if (
$uri == '') {
        
$uri $_SERVER['PHP_SELF'];
    }
    
$depth substr_count($uri'/') - 1;
    
$root '';
    for (
$x 1$x <= $depth$x++)
        
$root '../' $root;
    return 
$root;
}
 

and then you can access http://yourdomain/whatever/random.php like so:
Code: Select all
include (getRoot() . '/whatever/random');
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Includes Error Message

Postby orendon » Fri Mar 15, 2013 5:33 pm

Thanks so much !!!
Do I put the code below, that you sent, in a php.ini file in the root of the website or in what and/or elsewhere?

orendon

=================================
/*
*
* function getRoot
* Parameters:
* $uri = string path of the calling file; passed automatically from layout_top.php
* Returns:
* on success: string value to jump from current file to /root/
* on fail:
*/

function getRoot($uri = '') {
if ($uri == '') {
$uri = $_SERVER['PHP_SELF'];
}
$depth = substr_count($uri, '/') - 1;
$root = '';
for ($x = 1; $x <= $depth; $x++)
$root = '../' . $root;
return $root;
}
=============================
orendon
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Mar 15, 2013 2:07 pm

Re: Includes Error Message

Postby seandisanti » Mon Mar 18, 2013 7:27 am

personally I use it in a functions.php file that i include in the head section of pages.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron