<?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 'Connection error';
}
?>
Es wird ein Fehler angezeigt und die Variable $link kann in der dritten Datei nicht gefunden werden.
全局变量怎么还有单引号
常量可以直接使用
$link=mysqli_connect('DB_HOST', 'DB_USER', 'DB_PWD', 'DB_NAME');
去掉单引号