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
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

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.