Jump to content

define another database?


MSUK1

Recommended Posts

i tried googling but didnt really know how to "google it" as i cant think of a short phrase that best describes it..

 

but i want to chance the database setting of "localhost" in my php script to another websites database how do i acheive this?

Link to comment
Share on other sites

If you are trying to connect to an external database, permissions must be set on that database to allow access.  For example, with MySQL, you could need to grant access:

 

GRANT ALL PRIVILEGES ON db_name.* TO username@'IP_ADDRESS_HERE' IDENTIFIED BY 'password_here';

 

Then you create a new database connection using the above information.

 

EDIT: Forgot to mention if they are not using the default MySQL port you will need to define that as well.

Link to comment
Share on other sites

what IP address is that exactly, lets say we have

 

SERVER 1 & SERVER 2

 

server 1 holds the data

server 2 connects to server 1 for the data

 

so whose who in that situation?

 

sorry this part really baffles me, using localhost and keeping it all internal, no problem for me, but its vital that we get an external connection :/

 

thankyou"

Link to comment
Share on other sites

i have cpanel so i edited the remotesql  and added SERVER2

 

and in the php script i have this...

<?php
$host="174.37.172.25"; // Host name 
$username="db_System"; // Mysql username 
$password="password"; // Mysql password 
$db_name="table_StaceyOfficialLoginSystem"; // Database name 
$tbl_name="guestbook"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server "); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY id DESC LIMIT 1;";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
?>

 

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.