我试图在PHP中查询MySQL数据库但遇到错误

时间:2016-10-19 02:49:01

标签: php html mysql

我正在尝试使用以下代码查询我在PHPMyAdmin中创建的MySQL数据库

mysqli_connect.php
    

DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD' , 'password');
DEFINE ('DB_HOST','localhost');
DEFINE ('DB_NAME', 'login');

$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die("could not estabish connecton with database" . mysqli_connect_error())

?>

getinfo.php

<?php

require_once('mysqli_connect.php');

$query = "SELECT username , id";
$response = @mysqli_query($dbc, $query);

if($response){
echo '<table align="left"

cellspacing="5" cellpadding="8">
while($row = mysqli_fetch_array($response)){

echo'

$row['username']';

echo '</tr>';
}
} else {

echo "Couldn't issue database query<br />";
echo mysqli_error($dbc);

}

mysqli_close($dbc);

?>

但我一直收到这样的错误:

  

解析错误:语法错误,意外的'$ row'(T_VARIABLE),期待','或';'在第22行的C:\ Program Files(x86)\ ampps \ www \ user-management \ getinfo.php

请原谅我,因为我在调试时很糟糕,但你们可以帮帮我吗?

0 个答案:

没有答案