我是 PHP 新手。我需要一些帮助。
警告:mysql_connect() [function.mysql-connect]: 第 3 行 C:\xampp\htdocs\video\dbb.php 中的用户 'bp6am'@'localhost' 的访问被拒绝(使用密码:YES)无法连接。检查您的连接参数。
我知道我没有登录到数据库,但我无法通过它。
db.inc.php
<?php
define('MYSQL_HOST','localhost');
define('MYSQL_USER','root');
define('MYSQL_PASSWORD','pass');
define('MYSQL_DB','chat');
?>
dbb.php
<?php
require 'db.inc.php';
$db= mysql_connect('localhost','root','pass') OR
die('unable to connect. check your connection parameters.');
mysql_select_db(chat,$db) or die(mysql_error($db));
// create the user table
$query = 'CREATE TABLE IF NOT EXISTS
site user(
user_id INTEGER NOT NULL AUTO INCREMENT,
username VARCHAR(20) NOT NULL,
password CHAR(41) NOT NULL,
PRIMARY KEY (user_id)
}
ENGINE=MYISAM';
mysql_query($query,$db) or die (mysql_error($db));
//create the user info table
$query = 'CREATE TABLE IF NOT EXISTS
site user_info(
user_id INTEGER NOT NULL,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(20) NOT NULL,
email VARCHAR(50) NOT NULL,
city VARCHAR(20)
state CHAR(2)
hobbies VARCHAR(255)
FOREIGN KEY(user_id) REFERENCES site_user(user_id)
}
ENGINE=MYISAM';
mysql_select_db(chat,$db) or die(mysql_error($db));
//populate the user table
$query='INSERT IGNORE INTO site_user
(user_id,username,password)
VALUES
(1,"niharika",PASSWORD("niharika")),
(2,"admin",PASSWORD("admin"))';
mysql_select_db(chat,$db) or die(mysql_error($db));
//populate the user information table
$query='INSERT IGNORE INTO site_user_inefo
(user_id,first_name,last_name,email,city,state,hobbies)
VALUES
(1."niharika","katyan","niharikatyan@gmail.com",NULL,NULL,NULL),
(1."admin","smith","adminsmith@gmail.com",NULL,NULL,NULL)';
mysql_select_db(chat,$db) or die(mysql_error($db));
echo 'success!';
?>