The user name that PHP reads out of the file cannot be used to connect to the database
$this->conn = mysql_connect ($this->db_host, $this->db_user, $this->db_pwd);
if (! ( $this->conn))
{
Die (' Could not connect: '. Mydsql_error (' connection error '));
}
Echo ' Connection is successful!
';
$this->db_host, $this->db_user, $this->db_pwd are taken from the. ini file, the value of the host address and password can be used, but the user name is not, if the user name is directly connected to the string MySQL will not go wrong, if the user name is removed from the file for the connection, an error will occur, as follows:
Warning:mysql_connect (): Access denied for user ' noco ' @ ' 14.210.115.31 ' (using Password:yes) in C:\xampp\htdocs\projects \ship_thing_swap\mysql\connection.php on line 52
Fatal error:call to undefined function mydsql_error () in C:\xampp\htdocs\projects\ship_thing_swap\mysql\ Connection.php on line 55
Ask the big God this is God horse situation???
------to solve the idea----------------------
$this->conn = mysql_connect ($this->db_host, $this->db_user, $this->db_pwd);
if (! ( $this->conn))
{
Die (' Could not connect: '. Mydsql_error (' connection error '));
}
Spelling errors
------to solve the idea----------------------
observed that
' Noco ' @ ' 14.210.115.31 '
And
' Noco ' @ ' 14.210.115.31 '
The difference
It's obviously a lot more characters like spaces, carriage returns, line feeds, etc.
How did you read the INI file?
------to solve the idea----------------------
That is to remove the trailing white space characters (spaces, carriage returns, line feeds)
$this->db_host = Trim (fgets ($openfile));
$this->db_user = Trim (fgets ($openfile));
$this->db_pwd = Trim (fgets ($openfile));