具体代码如下:
class su{
private $host;
private $root;
private $pass;
private $name;
private $table;
function __construct($host,$root,$pass,$table){
$this->host=$host;
$this->root=$root;
$this->pass=$pass;
$this->table=$table;
}
function connect(){
$con=mysql_connect($this->host,$this->root,$this->pass) or die(mysql_error());
$sel=mysql_select_db($this->table,$con)or die(mysql_error());
$ch=mysql_query("set names 'gbk'");
}
function query($v){
return mysql_query($v) or die(mysql_error());
}
function insert($table,$name,$value){
$this->query("insert into $table ($name) value ($value)");
}
}
$p=new su('localhost','root','448824','susheguangli');
$p->insert("susheguangli","工号,姓名,性别,入职时间,入住宿舍,床位,户口,工资","6498,'高榆','男',new(),new(),3,'止州花东',2300");
?>
PHP100中,制作自己的PHP.MYSQL类中:Access denied for user ''@'localhost' (using password:
答案:2 悬赏:80 手机版
解决时间 2021-01-26 10:43
- 提问者网友:佞臣
- 2021-01-26 07:03
最佳答案
- 五星知识达人网友:怀裏藏嬌
- 2021-01-26 07:23
你的数据库没有密码,但是你配置了密码
全部回答
- 1楼网友:长青诗
- 2021-01-26 08:36
access denied for user ''@'localhost' to database
我在suse linux 10.2下用自带光盘用yast2安装mysql 5.0, 装好后在终端输入mysql, mysql
成功启动,退出,再输入 mysqladmin -u root password xxxxx, 出现错误: mysqladmin: connect to server at 'localhost' failed
error: 'access denied for user 'root'@'localhost' (using password: no)'
如先输入mysql,成功启动后输入use mysql,出现如下错误:access denied for user ''@'localhost' to database 'mysql'
还有,输mysql可以,输mysql -u root就出错了:
access denied for user 'root'@'localhost' (using password: no).
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯