-2

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>"; 
}

?>
SUM
  • 23
  • 1
  • 10

1 Answers1

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.

Jite
  • 5,761
  • 2
  • 23
  • 37
  • yeah good catch. Let's see if that'll get the OP going. OP might have to use `$t=mysql_select_db($dbname, $s);` too. – Funk Forty Niner Aug 28 '15 at 11:33
  • thing is though, OP posted already http://stackoverflow.com/questions/32253577/error-while-connecting-to-database-on-hosted-server and received an answer with the correct syntax http://stackoverflow.com/a/32255589/ and also stated this [in a comment...](http://stackoverflow.com/questions/32253577/error-while-connecting-to-database-on-hosted-server#comment52393070_32253577) `$a= mysqli_connect($localhost,$user,$pass);` but... they're mixing APIs in that comment. – Funk Forty Niner Aug 28 '15 at 11:36
  • what should i do for now..??? still that error "Access denied for the user....". ??@jite – SUM Aug 28 '15 at 11:46