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>";
}
?>
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
ormysqli
instead of using the deprecatedmysql_*
api.