PHP致命错误:require_once():无法打开所需文件

PHP致命错误:require_once():无法打开所需文件,php,android,mysql,Php,Android,Mysql,更新 谢谢您解决了这个问题,但是现在我收到了这个错误。连接尝试失败是因为连接方在一段时间后没有正确响应,或者建立的连接失败是因为连接的主机没有响应。我关掉了防火墙,没有任何防病毒软件 我将按照本教程将android应用程序连接到数据库 我在WAMPSERVER php版本5.4.3中托管我的php文件,我发现了以下两个错误 我已经试着修复这个错误好几个小时了,但是运气不好。你能帮我修复一下吗 警告:require\u onceC:\wamp\wwwC:\wamp\www\db\u connec

更新
谢谢您解决了这个问题,但是现在我收到了这个错误。连接尝试失败是因为连接方在一段时间后没有正确响应,或者建立的连接失败是因为连接的主机没有响应。我关掉了防火墙,没有任何防病毒软件

我将按照本教程将android应用程序连接到数据库

我在WAMPSERVER php版本5.4.3中托管我的php文件,我发现了以下两个错误 我已经试着修复这个错误好几个小时了,但是运气不好。你能帮我修复一下吗

警告:require\u onceC:\wamp\wwwC:\wamp\www\db\u connect.php:无法打开流:第12行C:\wamp\www\get\u property\u details.php中的参数无效

这个错误呢

致命错误:require_once:无法打开所需的“C:\wamp\wwwC:\wamp\www\db_connect.php”include_path=”。;第12行C:\wamp\www\get\u property\u details.php中的C:\php\pear

这些是我的档案 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

<?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();
    }

}

?>
获取_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);
}
?>
上面这一行是你的问题。您的路径是错误的,因为您告诉PHP文件位于当前目录中,并且位于名为C:\wamp\www\db\u config.PHP的路径中,这显然是错误的

define('DB_USER', "student"); 
define('DB_PASSWORD', "student2"); 
define('DB_DATABASE', "test"); 
define('DB_SERVER', "student.database.university.ac.uk"); 
?>
您的解决方案可能是删除_DIR _,这是不必要的,因为您似乎已经拥有文件的完整部分:

require_once "C:\\wamp\\www\\db_config.php"
上面这一行是你的问题。您的路径是错误的,因为您告诉PHP文件位于当前目录中,并且位于名为C:\wamp\www\db\u config.PHP的路径中,这显然是错误的

define('DB_USER', "student"); 
define('DB_PASSWORD', "student2"); 
define('DB_DATABASE', "test"); 
define('DB_SERVER', "student.database.university.ac.uk"); 
?>
您的解决方案可能是删除_DIR _,这是不必要的,因为您似乎已经拥有文件的完整部分:

require_once "C:\\wamp\\www\\db_config.php"

Quick note,您应该离开mysql并使用mysqli,因为mysql已被弃用并将被删除Quick note,您应该远离mysql,使用mysqli,因为mysql已被弃用并将被删除。不过,最好使用文件的相对路径,而不是绝对路径。我想说的是,最好使用文件的动态完整路径。谢谢您解决了这个问题,但现在我收到了这个错误,连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。我关闭了防火墙,但我没有任何抗病毒软件。不过,最好使用文件的相对路径,而不是绝对路径。我想说的是,最好使用文件的动态完整路径。谢谢你解决了这个问题,但现在我收到了这个错误,连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。我关掉了防火墙,没有任何防病毒软件