-2

我想在 byethost31.com(免费托管网站)上运行此代码,所以我面临“用户'test123'@'192.168.0.38'(使用密码:否)的访问被拒绝”控制台上的错误..

<?php
$localhost="*************";
$pass="*************";
$usename="*************";
$dbname="*************";

$s=mysql_connect($localhost,$pass,$username);
$t=mysql_select_db($dbname);


if($s ){
 echo "Mysql_connect is successful. <hr>";
}

if($t ){
 echo "Mysql_select_db is successful.. <hr>"; 
}

?>
4

1 回答 1

0

If you check the documentation for the mysql_connect function, you will see that the params it takes is: Server, Username, Password in that order. You send your password in as username instead of the other way.

I would recommend that you take a look at PDO or mysqli instead of using the deprecated mysql_* api.

于 2015-08-28T11:29:01.980 回答