0

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.

asprin
  • 9,579
  • 12
  • 66
  • 119
Slei
  • 15
  • 8
  • @user3702623: Are you sure that the mysql-Server is running and that he is configured to listen to the correct port? – Thomas Jul 09 '14 at 09:31
  • @ThomasE. Yes, the mysql server is running fine. About the configuration I don't really know about this, could you help me a bit about how to see this? – Slei Jul 09 '14 at 09:37
  • from what you wrote below in the answer-comment I take it the SQL-Server is running on another machine (as you mentioned remote-SQL-Server there?) – Thomas Jul 09 '14 at 09:40
  • Yes, the sql server is on a hosting (I don't know if I can't talk about other pages, so I won't say the name) – Slei Jul 09 '14 at 09:41
  • Are you sure the SQL-Server is reachable from the Location your Website is located on? – Thomas Jul 09 '14 at 09:44
  • Okay @ThomasE. Sorry for the inconvenience caused. Letz discuss here – Mohit S Jul 09 '14 at 09:46
  • @mohit like I said ist no Problem for me at all. only saw we are talking about the same Thing at 2 Locations. And I know I've no Problems at all there but other ppl who would like to also help could be confused by that. But back to Topic I think the next step is to see if the SQL-Server is reachable from the Server the Website is located on at all. – Thomas Jul 09 '14 at 09:47
  • @ThomasE. I didnt means that way and i understand. Okay, I found a [link](http://stackoverflow.com/questions/13769504/mysqlimysqli-hy000-2002-cant-connect-to-local-mysql-server-through-sock) which might help u. – Mohit S Jul 09 '14 at 09:49
  • I edited my original post with a bit more of information, can you check it? Sorry for my English btw :S – Slei Jul 09 '14 at 09:51
  • can you check the users on the mysql-Server? Your hunch about the IP COULD be correct as users on the mysql-dbs can be restricted to specific IPs (and some IPs I think even excluded) – Thomas Jul 09 '14 at 09:53
  • @ThomasE. I've a panel with 3 tabs: - General: A summary about the db. - Users: Just the name of the user and his state. - Access to host: An IP and his state. There is only one user and one IP so I assume that they are related. Also that IP is exactly the same than my public IP. – Slei Jul 09 '14 at 10:00
  • ok that was it not then. For the Connection itself do you put in the IP or the Name of the Domain? (when you open the Connection to the other server) – Thomas Jul 09 '14 at 10:16
  • Omg, finally I solved it. The problem was that my hosting gives me two different ways to connect to the db, one url that has the word "int" from internal between the url, and another that doesn't have this word. So, if I upload the website I have to use the url that has "int" and I want to look it locally, I have to use the one that doesn't have "int". Sorry for all this time guys and thank you too. – Slei Jul 09 '14 at 10:20
  • No Problem there. glad that you solved it. – Thomas Jul 09 '14 at 10:36

1 Answers1

0

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

Mohit S
  • 13,723
  • 6
  • 34
  • 69
  • I've installed WAMP and added the 'website folder' to the www wamp folder, is this the same than doing it in XAMPP? With this I can see php files that do not have a connection to the remote DB, so I guess the main problem is that I can't connect to the remote DB for some reason? – Slei Jul 09 '14 at 09:33
  • xampp and wamp are not very different from each other. and yaes the main Problem (as you can "see" the php files and more importantly the erorr message which Shows that the webserver is running) is the db error you get. See my question there in your original post (as comment there) – Thomas Jul 09 '14 at 09:34
  • In the WAMP do you see phpMyAdmin where you have ur db and all tables. If yes then look what username is created and is all the privilege given to the user for the DB. After that use the same in `$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);` i.e. eg:- host="localhost"; – Mohit S Jul 09 '14 at 09:37
  • @MohitShrivastava Yes but I want to do a remote connection to an online mysql server. The parameters are good – Slei Jul 09 '14 at 09:40
  • Then probably do share the more **code** for it. might be we can find something out there – Mohit S Jul 09 '14 at 09:42
  • guys can we either do that discussion in the main question comments or here?^^ I think doing the remote Connection discussion at two places is a bit confusing and also leads to double comments there. (doesnt matter to me at which Location but we should only use 1 though^^) – Thomas Jul 09 '14 at 09:44