简体   繁体   中英

PHP and DB connections with mysqli

I know this question may be a bit general but I have some questions that I would like to ask.

First of all I had a guy that did a website with some DB connections, etc, but now he left so I will have to continue his work soon. I've access to all the job he did but I have no idea how can I 'see' the website locally since it only have PHP files and I have some problems while trying to connect to the remote database. The error while connecting to the DB is:

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): There was an error while trying to connect because the host did not answer in time or maybe there was an error in the connection. (It's a traduction so maybe the original English error is a bit different.)

The connection is done by:

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);

So, my question is, how can I fix this to see that website locally so I could do all the tests I want before uploading it to the server.

Thanks for your time, Greetings.

EDIT

I have a mysql server on another machine (on a hosting) and is working correctly (I can access with other applications I've done on Java and there is no problem). If I enter to the website online (I mean, uploaded to the hosting where I have the DB), the connecctions and everything works good.

My problem is that I want to see the website locally to do internal test and do not destroy the online website, but as I already said, I can't connect to the DB.

It could be something related to IPs?

I'm pretty sure all the code works fine, problem is running it locally pretending to connect to an online DB.

Do download the XAMPP and install it on ur machine. then copy all the files and folder to xampp/htdocs/ and on the browser run like localhost/ and u wud be able to see all the files locally

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM