Remote MySql

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.

If you have MySQL hosted you might not have remote access to it. Otherwise, it’s a matter of setting your MySQL credentials in mysql_connect() or mysql_pconnect() to point to the correct server.

Would I put it in my admin panel script or what?

how do u make it connect to many databases and edit only the one that is logged in

You should just edit your script where it connects to the MySQL database. Instead of using ‘localhost’ you use the fully qualified domain name of the remote host.

yea I know, but how do I make it so I only use one script and then different people can login and edit their site. Like

Person A logins and edits his roster.
but Person B has a different website and wants to edit his other websites news page. How do I do that?

There are multiple ways of doing that, the easiest being to create a table which holds your user base. How to implement something like that is completely up to you though, as there are millions of ways to accomplish functionality like that.

can you tell me an easy way that is very effective? Thanks

I just did. Make a table with userdata in MySQL.

example?

What exactly are you trying to do? Have me build your script?
I won’t do it. I have my own scripts to think about.

It takes only a little bit of common knowledge and a curious set of mind to achieve what you want. I’m willing to bet you didn’t even touch google or php.net once on this matter, and if you did, you probably clicked it away again, not even bothering to try and understand what the hits meant, and decided to ask here instead to see if you can get a script for free. That’s not how it works. We provide help on scripts that you made, we don’t provide scripts. You can try phpscripts.com for that. We expect you to at least put some effort into the matter and so far, I’ve seen none of that.

You’re gonna have to make a list of things that you want. Login, database table setup, page templates, etc. Only then you can start coding and when things go wrong while coding, we can help you out. We won’t be doing your work for you.

And even if we did, do you think you could get your mind around it? If I said, ‘here’s a script that works’, and you run it and it doesn’t do what you want? Then what? I’m not gonna modify it for you, that’s your job. But since you didn’t write it yourself, you have no clue how to do it. It’s better to write your own script, so you know what goes wrong or what to change should something not be to your wishes.

im not asking for a script.

http://php.privatepaste.com/f0IKClQgM6

is my sql script. I just dont know what to add

Apart from a few small things, that script should work just fine. Is it the connection that goes wrong? What errors are you getting?

I just need it so I can have different people login and edit different websites which has the sql on their server. Then I am only using 1 admin script

Like I said: all you need to do is change the host, username and password for the mysql_connect() parameters. That way, you can connect to remote MySQL servers, if the server has been set up to allow remote connections.

But that will only allow 1 server to be accessed. I need multiple connects

If I am reading Zyppora right, with his previous comments and I understand what you are trying to do, Zyppora is right…

In the script you will need to change the mysql connection parameters depending on what they login in with. Hence, you will need a user/admin mysql table which will store the login username and password of the user and also store the mysql login/connection information.

I could be off base on what you are asking for and what Zyppora is trying to say, but that is just how I understood it.

What I think you’re trying to do, is have one login page, and select which local/remote MySQL server to login to.

It can even be accomplished in the same session, as a connection resource is an object to be stored in a variable :wink: Just create multiple variables, each containing a connection resource to a local/remote server. The trick is to keep track of which queries should be run on which connections.

Would This Work?

[code]$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);[/code]

Yes, that would work. On a sidenote, bumping is generally not-done, especially within 24 hours.

I tried that, but I just got errors.

I tried it on my web server and it didnt work :(

I used:

[code] $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);[/code]

and replaced:

$dbinfo = array();	$dbinfo[host] = 	"localhost";	$dbinfo[user] = 	"****";	$dbinfo[pass] = 	"****";	$dbinfo[db] = 	"****";		if ($dbinfo) {			$connection = @mysql_connect ($dbinfo[host], $dbinfo[user], $dbinfo[pass]);			if ($connection) {				@mysql_select_db ($dbinfo[db]);			} else {				echo "Unable to connect to database";				exit;			}		} else {			echo "You need to setup your mysql information";

in http://php.privatepaste.com/f0IKClQgM6

What did I do wrong?

Sponsor our Newsletter | Privacy Policy | Terms of Service