我是begginer,我总是有这个问题,当我要去移动我的网站从我的电脑到主机或服务器,一些代码无法运行,或者我总是看到一些错误。将网站从我的电脑移至主机或服务器?
我创建了一个数据库,我设置了一个特权(用户名和密码),但我有错误。
这是错误:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'mypassword'@'localhost' (using password: YES) in /home/qmelkir/public_html/include/connect.php on line 5 Access denied for user 'mypassword'@'localhost' (using password: YES)
,这是为了的mysql_connect:
$con=mysql_connect('localhost',$password,$username) or die(mysql_error());
如何解决呢?
以及如何在本地主机上工作不会有主机和服务器的问题?
谢谢
“localhost”是您运行代码的机器。为了达到这个目的,你需要a)让mysql运行在那里b)拥有正确的用户/密码凭据,所以确保这两个都是真实的(现在不是这样) – 2014-09-24 15:57:16
订单是主机,用户,密码请参阅http://php.net/mysql_connect – 2014-09-24 15:57:37
请[不要在新代码中使用'mysql_ *'函数](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-功能合PHP)。 *他们不再维护,并[已正式弃用](https://wiki.php.net/rfc/mysql_deprecation)*。看到[红色方块](http://uk.php。净/手动/ EN/function.mysql-connect.php)?学习[准备的语句](http://en.wikipedia.org/wiki/Prepared_statement),并使用[PDO](http://us1.php.net/pdo)或[MySQLi](http:// us1.php.net/mysqli)。 [这篇文章](http://php.net/manual/en/mysqlinfo.api.choosing.php)将帮助你决定哪些。 – 2014-09-24 15:59:02