php - 要求(MySQL); PHP 错误

标签 php mysql

您好,我已经创建了一个简单的 index.php 脚本来显示页眉和页脚,但是我一直在代码中遇到无法解决的错误 这是我的代码。

这个文件叫做 mysql.inc.php :

<?php
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'ecommerce1');
$dbc =mysqli_connect (DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
mysqli_set_charset($dbc, 'utf8');
function escape_data ($data, $dbc){
    if(get_magic_quotes_gpc()) $data =stripslashes($data);
    return mysqli_real_escape_string($dbc, trim ($data));
}?>

这是 config.inc.php :

<?php
if (!defined('LIVE')) DEFINE('LIVE', false);
DEFINE('CONTACT_EMAIL', 'you@example.com');
define ('BASE_URI', 'C:\xampp\htdocs\ecommerce\.');
define ('BASE_URL', 'localhost/ecommerce/html/index.php');
define ('MYSQL', BASE_URI . 'mysql.inc.php');
session_start();
function my_error_handler($e_number, $e_message, $e_file, $e_line,        $e_vars) {
    $message = "An error occurred in script '$e_file' on line $e_line:\n$e_message\n";
    $message .= "<pre>" .print_r(debug_backtrace(), 1) . "</pre>\n";
    if (!LIVE) { 
        echo '<div class="alert alert-danger">' . nl2br($message) . '</div>';
    } else { 
        error_log ($message, 1, CONTACT_EMAIL, 'From:admin@example.com');
        if ($e_number != E_NOTICE) {
            echo '<div class="alert alert-danger">A system error occurred. We apologize for the inconvenience.</div>';
        }
    }
    return true; 
} 
function redirect_invalid_user($check = 'user_id', $destination = 'index.php', $protocol = 'http://') {
    // Check for the session item:
    if (!isset($_SESSION[$check])) {
        $url = $protocol . BASE_URL . $destination; // Define the URL.
        header("Location: $url");
        exit(); // Quit the script.
    }
} ?>

这是 index.php :

<?php
require('./includes/config.inc.php');
require(MYSQL);
include('./includes/header.html');
?><h1>
    Welcome
</h1>
<?php /* PAGE CONTENT ENDS HERE! */
include('./includes/footer.html');
?>

This is the error i get Here is my project hierarchy

最佳答案

在 mysql.inc.php 尝试删除 BASE_URI 末尾的点之前,您的路径似乎有一个额外的点

关于php - 要求(MySQL); PHP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41846534/

相关文章:

列中某个值的 mySQL 条件未发生

更新查询上的 MySQL 高 lock_time 导致服务器卡住

php - Codeigniter 多维数组插入数据库

php - mysql:复制表中的某些行,更改重复行中的信息

php - 在 Controller 中使用爬虫

php - 将分页与查询字符串一起用于搜索表单,该表单的方法设置为在 codeigniter 中获取

php - 使用 PHP 的 echo,什么时候 .而且,重要吗?

mysql - 使用另一个表中一列的平均值

php - 备份MySql数据库?

php - 在本地 Wamp 上设置远程 WordPress 站点时出现问题