[英]PHP Fatal error: require_once(): Failed opening required
UPDATE thank you that solved the problem , but now I get this error "A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond. " I turned off the firewall and I don't have any antiviruse software UPDATE谢谢您,解决了该问题,但是现在我收到此错误“连接尝试失败,因为一段时间后连接方未正确响应,或者由于连接的主机未能响应而建立连接失败。”我关闭了防火墙而且我没有任何防病毒软件
I'm following this tutorial to connect android app to the database http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ 我正在按照本教程将android app连接到数据库http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
I'm hosting my php file in WAMPSERVER PHP Version 5.4.3 I get these two errors I've been trying to fix this error for hours but no luck could you please help me fix it 我将我的php文件托管在WAMPSERVER PHP版本5.4.3中,我遇到了两个错误我已经尝试修复了几个小时的错误,但是运气不好,请您帮我修复一下
" Warning: require_once(C:\\wamp\\wwwC:\\wamp\\www\\db_connect.php): failed to open stream: Invalid argument in C:\\wamp\\www\\get_property_details.php on line 12" “警告:require_once(C:\\ wamp \\ wwwC:\\ wamp \\ www \\ db_connect.php):无法打开流:第12行的C:\\ wamp \\ www \\ get_property_details.php中的参数无效”
and this error 和这个错误
"Fatal error: require_once(): Failed opening required 'C:\\wamp\\wwwC:\\wamp\\www\\db_connect.php' (include_path='.;C:\\php\\pear') in C:\\wamp\\www\\get_property_details.php on line 12" “严重错误:require_once():无法在C:\\ wamp \\ www \\中打开所需的'C:\\ wamp \\ wwwC:\\ wamp \\ www \\ db_connect.php'(include_path ='.; C:\\ php \\ pear')第12行的get_property_details.php”
these are my files db_config.php 这些是我的文件db_config.php
define('DB_USER', "student");
define('DB_PASSWORD', "student2");
define('DB_DATABASE', "test");
define('DB_SERVER', "student.database.university.ac.uk");
?>
db_connect.php db_connect.php
<?php
class DB_CONNECT {
function __construct() {
$this->connect();
}
function __destruct() {
$this->close();
}
function connect() {
require_once __DIR__ . "C:\\wamp\\www\\db_config.php";
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
return $con;
}
function close() {
mysql_close();
}
}
?>
get_student_details.php get_student_details.php
<?php
/*
* Following code will get single student details
* A student is identified by student id (student_id)
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . "C:\\wamp\\www\\db_connect.php";
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["student_id"])) {
$student_id = $_GET['student_id'];
// get a student from students table
$result = mysql_query("SELECT * FROM TABLE_STUDENT WHERE student_id = $student_id");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$student = array();
$student["student_id"] = $result["student_id"];
$student["student_fname"] = $result["student_fname"];
$student["student_lastName"] = $result["student_lastName"];
$student["address"] = $result["address"];
$student["postcode"] = $result["postcode"];
$student["grade"] = $result["grade"];
// success
$response["success"] = 1;
// user node
$response["student"] = array();
array_push($response["student"], $student);
// echoing JSON response
echo json_encode($response);
} else {
// no student found
$response["success"] = 0;
$response["message"] = "No student found";
// echo no users JSON
echo json_encode($response);
}
} else {
// no student found
$response["success"] = 0;
$response["message"] = "No student found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
require_once __DIR__ . "C:\\wamp\\www\\db_config.php";
The above line is your problem. 上一行是您的问题。 You're path is wrong because you are telling PHP the file is located in the current directory and in a path called "C:\\wamp\\www\\db_config.php" which clearly is incorrect. 您输入的路径错误,因为您告诉PHP该文件位于当前目录中,并且位于名为“ C:\\ wamp \\ www \\ db_config.php”的路径中,这显然是错误的。
Your fix probably is to remove the __DIR__
which is not necessary since you seem to have the full patgh to the file already: 您的解决方法可能是删除__DIR__
,这是不必要的,因为您似乎已经对文件具有完整模式了:
require_once "C:\\wamp\\www\\db_config.php"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.