2011-02-18 129 views
-3

嗨 我已經包含這在我的index.php

include $page; 

,但它不工作現場服務器,但工作正常在我的本地上。 我還在index.php頁面的頂部包含了include ('includes/_ini.php');,其中$page被定義。 請建議

在服務器給它下面的警告

Warning: include(?pgid=1&parid=&rid=1&lang=1) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/mysite.com/index.php on line 290 

Warning: include(?pgid=1&parid=&rid=1&lang=1) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/mysite.com/index.php on line 290 

Warning: include() [function.include]: Failed opening '?pgid=1&parid=&rid=1&lang=1' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/mysite.com/index.php on line 290 
+0

集中顯示錯誤報告,看看它說。你可能會錯誤地鏈接代碼是危險的文件 –

+2

。不要在包含命令中使用變量。您可能會遇到安全問題!遠程文件包含或他們可以查看您的祕密文件! –

+0

這是一場等待發生的重大災難。猜猜當啓用URL封裝並且將'?page = http:// domain.com/script.txt'傳遞給腳本(其中script.txt是包含一些PHP代碼的文件)時會發生什麼。 – wimvds

回答

5

include()聲明包含並評估**specified file**

看看你的警告:

Warning: include(?pgid=1&parid=&rid=1&lang=1) 

比較這個(代碼)

include $page; 

所以=>

$page = ?pgid=1&parid=&rid=1&lang=1 

**specified file**不喜歡你的格式在這裏:?pgid=1&parid=&rid=1&lang=1 (它只是URL而不是路徑o ˚F現有文件)

例如:

/* This example assumes that www.example.com is configured to parse .php 
* files and not .txt files. Also, 'Works' here means that the variables 
* $foo and $bar are available within the included file. */ 

// Won't work; file.txt wasn't handled by www.example.com as PHP 
include 'http://www.example.com/file.txt?foo=1&bar=2'; 

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the 
// local filesystem. 
include 'file.php?foo=1&bar=2'; 

// Works. 
include 'http://www.example.com/file.php?foo=1&bar=2'; 

$foo = 1; 
$bar = 2; 
include 'file.txt'; // Works. 
include 'file.php'; // Works. 

更多到這裏看看: http://php.net/manual/en/function.include.php

2

看來$page是URL格式。它不是文件的路徑。

您必須使用path of file to include

文件名必須作爲

folder/file1.php用於linux(使用/)

folder\file1.phpwindows(使用)

+0

但它工作正常我的本地 – vanurag

+0

你可以發佈你的代碼。以便可以確定問題。 – Gaurav

4

警告是明確的; $page包含?pgid=1&parid=&rid=1&lang=1這不是包含的有效文件名。有效的文件名將是例如foo/bar.php

+0

是的,這是有效的名稱..請參閱--www.mysite.com/?pgid=1&parid=&rid=1&lang=1 – vanurag

+2

是的,它的網址,但沒有存在的文件的路徑。 – kn3l