Jump to content
  • 0

Top PHP Scripts. How to connect from webserver to database?


rubix123

Question

Hi I want to use php scripts to rank players, but I can't get the scripts to connect to my database. I am using the default port 3306, which is opened on my router.

 

Since I am behind a router would I have to include the port some where? How would it know which computer to connect to?

 

$db_link = mysql_connect('host', 'user', 'password');

 

 

Any help would be appreciated :)

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Thx for the reply. I am using a Linksys router. Would that be under

 

Applications and Gaming -> Port Triggering

 

I have only opened ports on my router I've never needed to point a port to a specific machine, so Im not exactly sure what to search. :(

Link to comment
Share on other sites

  • 0

We are talking about the same thing!

Do the same thing about 3306 tcp/udp port...

You also have to create a user for the database that accepts connections from remote machines.

Link to comment
Share on other sites

  • 0

Yeap... it seems to be the right one.

 

For a detailed guide find your router in this list: http://portforward.com/english/applications/port_forwarding/MySQL_Server/MySQL_Serverindex.htm

Link to comment
Share on other sites

  • 0

They don't have a guide for my router.

 

My ports are already open and I made a MySQL user. That image I posted earlier also doesn't seem like the right page because it doesn't have the IP of the computer I want it to connect to... I checked "Canyouseeme.org" and port 3306 is open but now I have no way of telling the script which computer to connect to on that IP.

 

 

Link to comment
Share on other sites

  • 0

Oops, I thought it was port range forward which is the right one!

Can you give me a clear summary of your project?

Where is the mysql server? Where is the webserver? Where is the game server?

 

 


If the web server is hosted on a remote machine and the database server on localhost, you have to use the ROUTER'S IP(your WAN ip, www.whatismyip.com) on your php scripts...

Link to comment
Share on other sites

  • 0

I have a test game server on my dedicated PC which has opened ports and players from other countries can connect with no problem so stuff like that isn't blocked.

 

My web server with the stats script is through a web hosting company

Link to comment
Share on other sites

  • 0


If the web server is hosted on a remote machine and the database server on localhost, you have to use the ROUTER'S IP(your WAN ip, www.whatismyip.com) on your php scripts...

 

It is currently set to that :/

Link to comment
Share on other sites

  • 0

Why the hell do you want to open your Router's ports?

 

Ask your company if 3306 is open...

The IP(/hostname) you have to use on php scripts is the server's one.

 

Let me explain you something.

Your PC has nothing to do with the webserver or the gameserver(including the mysql server)...

The only connection we need here is between the webserver and the mysql server, thus the server's 3306 tcp/udp port needs to be open.

Link to comment
Share on other sites

  • 0

Im sorry for the confusion.. Let me explain just to be clear.

 

Web Server - Has the PHP scripts loaded on it. Hosted by a web company

 

Game Server - This is hosted on my LAN, thats why I opened the ports 3306 tcp/udp on my router.

 

MySQL Server - This is hosted on the same PC as the game server.

 

---------------------

 

I just tried installing WAMP on the server PC. I successfully got the php scripts to load and connect to the database.

 

When I set up the MySQL connection I made sure to check "Allow access from remote machines", and I opened the ports, but the scripts still don't connect to the database when they are uploaded to a remote web server.

 

Link to comment
Share on other sites

  • 0

Thank you for clearing out the whole situation.

My basic knowledge says "Allow access from remote machines" is not enough.

Open navicat or any MySQL server browser and go to the user creation menu.

Fill in the fields with your settings and as a "host" put the webserver's IP or hostname(however, you can use the symbol "%" to allow access from ANY remote host).

navicat-create-blogger-user-with-pw-123451.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...