Jump to content

Mysql Connection (remote)


Phpfanboi

Recommended Posts

<?php

$dbhost = "localhost";    <-(replace 'localhost' with server ip ?)

$dbuser = "root";

$dbpassword = '';

 

$dbdatabase = "productsdb";

and so on ..

 

For remote access to my hosted database via another machine what do i replace "localhost" with ? is it the ip address for my server? How do i point this function to the remote server?

 

I know i have to allow for the incoming ip address (users machine) in c-panel using the wild card feature , but i am not sure if i am meant to replace the "localhost" part in my connection function , with the ip address where my database is remotely living.

 

If i am meant to be using the web host ip address , im guessing i have to find it on c-panel , how do i do this , any information would be good thankyou.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/211474-mysql-connection-remote/
Share on other sites

Yes, you need to replace the localhost domain with either the ip address or domain name of your mysql server database.

So i can use for instance ;

$dbhost = "http://www.mydatabase.com";   

$dbuser = "root";

$dbpassword = '';

 

$dbdatabase = "productsdb";

and so on ..

 

Is this the correct method?Also can you help me find my ip address for my server , is it located in c-panel?Thank you very much for your hastly reply.cheers

 

No, http is the webs protocol, not part of a domain name. www is generally a subdomain on that server specifically used for serving web content. Your hostname entry should look more like.....

 

$dbhost = "mydatabase.com";

 

Be aware though that using a hostname is going to be slower than an ip. If you know the domain you can find the ip easily enough by pinging it (I don't/won't use Cpanel).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.