0

Actually I am new to php. I created login page using php .after clicking on submit button its showing

"Access denied for user ''@'localhost' (using password: NO)"

i am using amazon linux server. In that i can login with my username and password but using php script i cant connect to the my database

Here my dbconn.php scirpt

<?php

    class UserValue{

    private $SERVER;

    private $HostName;

    private $Db_UserID;

    private $Db_Password;

    private $Database;

    function __construct($HostName, $Db_UserID, $Db_Password, $Database){

    $this->HostName = '*****';

    $this->Db_UserID = '****';

    $this->Db_Password = '****';

    $this->Database = '****';

    $this->SERVER = $_SERVER[HTTP_HOST];

    if ($this->SERVER !== 'www.******.com') die("Entered incurrect Hostname!!!");

    $connect = mysql_connect($this->HostName, $this->Db_UserID, $this->Db_Password);

    if (!$connect) die('Could Not Connect to '.$this->HostName.' throwing error'.mysql_error());

    $db_conn = mysql_select_db($this->Database);

    if (!$db_conn) die('Could Not Connect to '.$this->Database.' throwing error'.mysql_error());

    }
}

?>

please help me how to fix this issue

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Sai Kumar
  • 53
  • 1
  • 9
  • 1
    Possible duplicate of [access denied for user @ 'localhost' to database ''](http://stackoverflow.com/questions/8621649/access-denied-for-user-localhost-to-database) – Drenmi Oct 28 '15 at 19:01
  • You've probably used an out-of-date tutorial as the old mysql_* extension which you've used was deprecated in version 5.5 of PHP (the current version of PHP) and is being removed in version 7 of PHP (the next version). You need to use either the mysqli_* extension or PDO – SpacePhoenix Oct 28 '15 at 19:46
  • i am using php 5.5 versioin – Sai Kumar Oct 30 '15 at 06:39

1 Answers1

0

You need to add your IP or * in the db server while creation so that it can receive request from your machine.

user3307291
  • 708
  • 1
  • 8
  • 11