问题
I want to run this code on byethost31.com (free hosting site) so i am facing " Access denied for user 'test123'@'192.168.0.38' (using password: NO)" Error on console..
<?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>";
}
?>
回答1:
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.
来源:https://stackoverflow.com/questions/32269976/access-denied-for-user-test123192-168-0-38-using-password-no