Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP: Connection to a MYSQL host externally.

  • 24-10-2010 02:01PM
    #1
    Closed Accounts Posts: 6,281 ✭✭✭


    Hi all,

    I have recently got another website domain and host and for the moment would like to mirror my old website onto the new one.

    I'm trying to connect to a database on my old server so I can query it in the same way on my new site.

    Is there anyway to find out what my external MYSQL IP/address is?

    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    who hosted your old server? they should be able to tell you the address, then you can use

    [php]
    link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
    [/php]

    instead of the usual or what you might have been using:

    [php]
    link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    [/php]


  • Closed Accounts Posts: 6,281 ✭✭✭Ricky91t


    who hosted your old server? they should be able to tell you the address, then you can use

    [php]
    link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
    [/php]

    instead of the usual or what you might have been using:

    [php]
    link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    [/php]

    Thanks for that, I'm still using both hosts ( it's hostso.com btw!) I spoke to them on their support and using my function I just change localhost to jet.nseasy.com:2082' but it's not connecting, Was wondering if there was any way like making a info.php script to find a direct link to mt databases.


  • Registered Users, Registered Users 2 Posts: 67 ✭✭The Gibmiester


    I know with Blacknight there's a checkbox in the control panel you need to tick to allow an external host to access a database. You need to add the IP of the external host too. Maybe you're hosting has something similar.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    I know with Blacknight there's a checkbox in the control panel you need to tick to allow an external host to access a database. You need to add the IP of the external host too. Maybe you're hosting has something similar.
    +1 on this. Think MySQL by default only allowed localhost to access the server. Depends how the host has it configured.


  • Registered Users, Registered Users 2 Posts: 339 ✭✭spoonface


    who hosted your old server? they should be able to tell you the address, then you can use

    [php]
    link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
    [/php]instead of the usual or what you might have been using:

    [php]
    link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    [/php]

    One question on these - the above specifies server,user and password. But how does the database name within that server get specified? i.e. how does it know which database you want to connect to?


  • Advertisement
  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    spoonface wrote: »
    One question on these - the above specifies server,user and password. But how does the database name within that server get specified? i.e. how does it know which database you want to connect to?

    Make the connection first, then select the db with mysql_select_db


Advertisement