Warning: mysql_real_escape_string(): Access denied for user 'root'@'localhost' (using password: NO) …/public_html/checklogin.php

后端 未结 3 1807
太阳男子
太阳男子 2021-01-29 14:07

Thank you guys for the wonderful job you are doing. I just uploaded my website on the the remote server and it brought me back this error message.

Warning: mysq         


        
相关标签:
3条回答
  • 2021-01-29 14:59

    Or you don't have remote acces privileges on you mysql servers user. Simply change localhost to % will grant root access to public network. Don't forget to flush privileges.

    0 讨论(0)
  • 2021-01-29 15:00

    You probably forgot to supply correct username and password to connect to MySQL server. Here mysql_connect("50.28.8.6", "root","")

    0 讨论(0)
  • 2021-01-29 15:03

    The problem is you use mysql_real_escape_string() function first then you connect:

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    
    mysql_connect("50.28.8.6", "root","") or die(mysql_error()); //Connect to server
    

    Solution is to connect first then use function mysql_real_escape_string()

    //Connect to server
    mysql_connect("50.28.8.6", "root","") or die(mysql_error()); 
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    

    This is because mysql_real_escape_string() requires the connection.

    0 讨论(0)
提交回复
热议问题