Jump to content

Remote MySql


unidox

Recommended Posts

I need some help.

 

I have an admin panel, and I like it, however I dont want to give my script out. So I was just wondering how I set my panel up so I add a domain, which has their own mysql files on it, and can login on the panel and edit their site without having to have the files on their webserver, and just mine.

Link to comment
Share on other sites

So I was just wondering how I set my panel up so I add a domain, which has their own mysql files on it, and can login on the panel and edit their site without having to have the files on their webserver, and just mine.

I am confused and didn't understand.

If you want to access another MySQL Server on another domain use

mysql_connect('other-domain.com', 'user_name', 'Password')

Link to comment
Share on other sites

Yes you can just use:

 

<?php

$conn = mysql_connect("1.1.1.1", "user", "pass");

?>

 

But you may need to alter the MySQL settings on the remote server to allow the server you're running the site on to access the database remotely.

Link to comment
Share on other sites

i sort of need to do the same thing ,but through visual basic ( thats another story)

 

what my host says is that you either need a static IP, and they can allow that through their firewall, or ican use SSH tunneling

 

please dont ask what either mean, i havent really looked into either, but though tthose things might help you with your site.

 

good luck

Link to comment
Share on other sites

$conn1 = mysql_connect("1.1.1.1", "user", "pass");
$conn2 = mysql_connect("2.2.2.2", "user", "pass");

$query = "SELECT * FROM table1";

$results_from_conn1 = mysql_query($query, $conn1);

$results_from_conn2 = mysql_query($query, $conn2);

 

Same query, two different servers, presumably two different results.

 

You can connect to as many database servers as your php server has resources for (each connection does take memory and such), and you can query each one independently in the same script.

 

Link to comment
Share on other sites

how do I set it up on the other end.

 

The user needs to login and give themselves permission to login from your domain. Something like...

 

GRANT ALL PRIVILEGES ON *.* TO username@yourdomain.com IDENTIFIED BY "password";

 

There are serious security issues involved with what you are wanting to do. There is no way I would grant access permissions from someone elses domain. This makes it alot easier for you to break into there db.

Link to comment
Share on other sites

I dont get it. What I need is for my domain to hold the script. Then they goto my site and login to the admin panel. Then they can edit thir site. My admin panel only changes the sql. There server will have the non admin files like index.php and they will also have the sql on their server.

Link to comment
Share on other sites

Yea, I use localhost. So all I have to do is

 

$conn1 = mysql_connect("1.1.1.1", "user", "pass");

$conn2 = mysql_connect("2.2.2.2", "user", "pass");

 

$query = "SELECT * FROM table1";

 

$results_from_conn1 = mysql_query($query, $conn1);

 

$results_from_conn2 = mysql_query($query, $conn2);

 

but what is table1?

Link to comment
Share on other sites

I will try when I get home

 

Try what? This example...

 

<?php

  $conn1 = mysql_connect("1.1.1.1", "user", "pass");
  $conn2 = mysql_connect("2.2.2.2", "user", "pass");

  $query = "SELECT * FROM table1";

  $results_from_conn1 = mysql_query($query, $conn1);

  $results_from_conn2 = mysql_query($query, $conn2);

?>

 

simply shows how to connect to two different database servers and run the same query on each. You still need to make sure both mysql servers (1.1.1.1 and 2.2.2.2) allow a connection to be made from your domain.

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.