0

在阅读了大量文章并尝试了很多代码之后,我无法从我的本地主机中包含一个 php 文件。并且知道我什至无法在 javascript 代码中指定路径,例如

xmlhttp.open("GET","/DB/ajax/ajaxDeleteRow.php?q="+commentId,true);

我想包含文件:drawTableSqlString.php,它与我的文件位于同一文件夹中:CommentTableAndDeleteAjax.php。它们在文件夹中:C:\xampp\htdocs\DB\ajax

到目前为止我尝试了什么:

1. echo get_include_path();我得到了显示:.;C:\xampp\php\PEAR 然后我试图将我的文件复制到该文件夹​​中-> 没有用。

  1. 回声目录名(drawTableSqlString.php);

我收到一个错误:注意:使用未定义的常量 drawTableSqlString - 在第 36 行的 C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php 中假定为“drawTableSqlString”

3. 将 php.ini 中的路径从 "include_path=".;C:\xampp\htdocs"" 更改为 include_path=".;C:\xampp\php\PEAR"

我试过了:

include ('\DB\ajax\drawTableSqlString.php');
include ('DB\ajax\drawTableSqlString.php');

给出一个错误,看起来像这样:

警告:include(\DB\ajax\drawTableSqlString.php):无法打开流:第 33 行的 C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php 中没有此类文件或目录

警告:include():在 C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php 中打开 '\DB\ajax\drawTableSqlString.php' 以包含 (include_path='.;C:\xampp\htdocs') 失败第 33 行

基于其他论坛条目,我也尝试了下面的所有代码,但没有任何效果:

//************************** include DB connection INFOS
//$xajax_dir = 'C:\\xampp\\htdocs\\DB\\ajax'; 
//include( $xajax_dir . DIRECTORY_SEPARATOR . 'drawTableSqlString.php' );   

//include('./localhost/DB/ajax/CommentTableAndDeleteAjax.php' );   
//include('localhost/DB/ajax/CommentTableAndDeleteAjax.php' );   
//include('./DB/ajax/CommentTableAndDeleteAjax.php' );   
//include('DB/ajax/CommentTableAndDeleteAjax.php' );   
//include('C:/xampp/htdocs/localhost/DB/ajax/drawTableSqlString.php' );   
//include_path = ('.;C:\xampp\php\PEAR','C:\xampp\htdocs\DB\ajax\drawTableSqlString.php');
//include('127.0.0.1/DB/ajax/CommentTableAndDeleteAjax.php' ); 
//include('C:\xampp\htdocs\DB\ajax\drawTableSqlString.php');
//FROM http://stackoverflow.com/questions/17003614/including-files-from-include-path-not-working-as-expected
//include_once ('/DB/ajax/drawTableSqlString');
 //include_once("C:/xampp/htdocs/DB/ajax/drawTableSqlString.php");
// include __DIR__ . 'drawTableSqlString.php';
// include '../drawTableSqlString.php';
//include('http://127.0.0.1/DB/ajax/CommentTableAndDeleteAjax.php' ); 
//$xajax_dir = 'C:\\xampp\\htdocs\\DB\\ajax'; 
//include( $xajax_dir . DIRECTORY_SEPARATOR . 'drawTableSqlString.php' );   
//include ('drawTableSqlString.php');
//include_path=".;c:\php\includes"

//http://www.php.net/manual/en/ini.core.php#ini.include-path
//set_include_path(".;c:\xampp\htdocs\DB\ajax");

//include ('drawTableSqlString.php');

//echo get_include_path();

任何帮助都会非常感激。

编辑:

由于我更改了 php.ini 的某些部分,因此在盯着 XAMPP 说时出现错误:

致命错误:指令“register_globals”在 PHP 中不再可用

4

0 回答 0