There is a problem connecting to the database with include
Will
Will 2017-11-24 19:38:02
0
3
1416

<?php
define('DB_HOST', 'localhost');
define('DB_USER', '****');
define('DB_PWD', '****');
define('DB_NAME', 'login_in_infor');
define('DB_CHARSET', 'utf8');
?>

<?php
include 'config.php';
$link=mysqli_connect('DB_HOST', 'DB_USER', 'DB_PWD', 'DB_NAME');
if(mysqli_errno($link))
{
    mysqli_error($link);
    exit;
}
mysqli_set_charset($link, 'DB_CHARSET');
?>

<?php
header('Content-Type:text/html;charset=utf-8');
include 'connection.php';
$count_sql="select count(id) as c from login_in";
$result_count=mysqli_query($link,$count_sql);
if($result_count)
{
    $data=mysqli_fetch_assoc($result_count);
    $count=$data['c'];
    echo $count;
}
else {
    echo '连接错误';
}
?>

显示出错,在第三个文件中找不到$link变量。


Will
Will

reply all(3)
心与境合

Why do global variables still have single quotes?

ABB海久机电-徐生

Constants can be used directly

路过

$link=mysqli_connect('DB_HOST', 'DB_USER', 'DB_PWD', 'DB_NAME');

Remove the single quotes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template