求助:Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'loc
最近自学php,然后试着写了个程序:<?php
header("Content-Type:text/html; charset=utf8");
define("DB_HOST","localhost");
define("DB_USER","root");
define("DB_PASS","root");
$id=$_POST['ID'];
$password=$_POST['Password'];
$_sql = file_get_contents('user.sql');
$_arr = explode(';', $_sql);
$_mysqli = new mysqli(DB_HOST,DB_USER,DB_PASS);
if (mysqli_connect_errno()) {
exit('连接数据库出错');
}
else {echo'fun';}
foreach ($_arr as $_value) {
$_mysqli->query($_value.';');
}
//$sql = "select * from user where ID = '$id' and password = '$password'";
$result = mysql_query("select * from user where ID = '$id' and password = '$password'");
$rows=mysql_num_rows($result);
if($rows)
{echo '<script>alert("successfully send");location.href=./index.html"</script>';exit();}
else{echo'<script>alert("username or password wrong")</script>';exit();}
$_mysqli->close();
$_mysqli = null;
?>
报错Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'localhost' (using password: NO) in D:\phpStudy\WWW\dcgz\config.php on line 21
请问哪里写错了,怎么改啊谢谢各位大神