doutao4938 2016-02-12 11:46
浏览 109

用户'a9802737_mystor'@'10.1.1.31'拒绝访问(使用000webhost.com)

I'm creating an e-commerce website for our project following a series in youtube(link: https://www.youtube.com/watch?v=YaII5QhNCH0&index=2&list=PL5t0hrp1JCovPTJDC3lR3V5pKDG-xL5mI). It's a tutorial for an e-commerce website using PHP(IDE: Adobe Dreamweaver) and MySql.

As followed through the tutorial, I availed a free web hosting from 000webhost.com. Here(at 000webhost.com) I created a database with:

name ="a9802737_mystore"

host = "mysql9.000webhost.com"

username = "a9802737_mystore"

Then as indicated in the tutorial, I made a connect_to_mysql.php file.

<?php 

   //connect_to_mysql.php

   $db_host = "mysql9.000webhost.com";
   $db_username = "a9802737_mystore";
   $db_pass = "*******";    
   $db_name = "a9802737_mystore";

   mysql_connect("$db_host","$db_username","$db_pass") or die("could not connect to mysql.");
   mysql_select_db("$db_name") or die("no database");

?>

then create a table through code:

<?php 
   //create_admin_table.php

   require "connect_to_mysql.php";

   $sql_command = "CREATE TABLE admin(
        id int(11) NOT NULL auto_increment,
        username varchar(255) NOT NULL,
        password varchar(255) NOT NULL,
        last_log_date date NOT NULL,
        PRIMARY KEY(id),
        UNIQUE KEY username(username)
        )";

   if(mysql_query($sql_command)){
       echo"Your admin table has been created successfully!";
   }    else{

       echo"Critical Error: admin table has not been created";
   }


 ?>

now I'm getting an error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user ' a9802737_mystor'@'10.1.1.31' (using password: YES) in /home/a9802737/public_html/storescripts/connect_to_mysql.php on line 10

error

How can I fix this guys?

A big thank you to everyone! :)

UPDATE: I used PDO instead of mysql_connect then I successfully connected.

But When I execute my create_admin_table.php is gives me this error:

see this error

  • 写回答

1条回答 默认 最新

  • doujianmin6527 2016-02-12 13:29
    关注

    Thank you EVERYONE! I can now successfully connect to my database using PDO and "mysql9.000webhost" as my host and now can create a table through PDO also. Again thank you Stackoverflow!!

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能