0

Before I get into the question, I ran into a lot of questions, both on this website, as well as a bunch of others, however none of the solutions there helped, and so decided to post a question with my exact situation.

So I am currently building a website, and am trying to connect it to a MySQL database I have created on phpmyadmin through hostgator. I am currently using 000webhost.com to host my webpages, as the computer I am working on does not have an ftp client, and am unable to install it as of now. As such, I decided to upload the files onto there temporarily as I build it, as they are dynamic webpages. Whenever I load up the page, however, I receive this error:

Warning: mysqli_connect(): (HY000/1045): ProxySQL Error: Access denied for user...

where the "..." just lists my username and filepath to the file.

this is my php code to connect to the database:

<?php
define("DB_SERVER","localhost");
define("DB_USERNAME","**user**");
define("DB_PASSWORD","**password**");
define("DB_DATABASE","**database_name**");
if(!mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD)){
    echo"Failure";
}
else{
    echo"Success!";
}
?>

I double- and triple-checked the database username, password and name, however to no avail. Thanks a lot in advanced!

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Sal
  • 1,471
  • 2
  • 15
  • 36
  • Please, ALWAYS show us ALL the error message. If you summarise it we loose possibly vital information – RiggsFolly Jul 11 '18 at 23:37
  • Did you check all those parameters with the CPanel settings – RiggsFolly Jul 11 '18 at 23:39
  • Do this search on Google `000webhost Warning: mysqli_connect(): (HY000/1045): ProxySQL Error: Access denied for user` and you will see a bunch of similiar question on the 000webhost help system – RiggsFolly Jul 11 '18 at 23:41

2 Answers2

0

To answer your initial question, there is no call to connect.

define("DB_SERVER","localhost");
define("DB_USERNAME","**user**");
define("DB_PASSWORD","**password**");
define("DB_DATABASE","**database_name**");

$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);

then test your connection.

As for setting up a localhost for development, if you are using Windows I would suggest XAMPP, it is pretty much download and say yes to all.

tim
  • 677
  • 9
  • 11
0

You have to change your DB Server location due to you are not using the same web server as your hosting. Change this define("DB_SERVER","localhost"); to define("DB_SERVER","YOUR_REMOTE_DB_SERVER"); Also you have to enable remote access in your mysql database. You can check this similar topic

MNI Noyon
  • 98
  • 1
  • 1
  • 10
  • Even if you change the settings to the remote ones, please make sure your MySQL server allows remote access. Otherwise it will not work – Ulrich Dohou Jul 12 '18 at 07:26
  • Huh such a simple fix. I moved the files onto my HostGator file manager, without changing any of the contents, and it works flawlessly. Thank you! – Sal Jul 12 '18 at 15:42