db on a different server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sanch3x
Forum Newbie
Posts: 2
Joined: Wed Jul 06, 2005 11:25 am

db on a different server

Post by sanch3x »

Hey guys,

I got a forum coded for me with php. Anyways, the server where my website is located is blocked at my work because it was identified as a "game" site (I think it has to do with the DNS or what not)...

So the thing is, I'd like to make a "mirror site" that would be on an acceptable server but I would like to use the database on the blocked one. How can I query a DB that is on a different server?

The site is already running so is it just a different in connections, or sql queries or what?

Thanks for any help :)

Seb
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Assuming you are using mysql: http://www.php.net/mysql_connect


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
ysql_connect[/url]


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
sing mysql: http://www.php.net/mysql_connect


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
sing mysql: http://www.php.net/mysql_connect


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
ttp://www.php.net/mysql_connect[/url]


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
onnect[/url]


For example, your database is at forbidden.example.com

Code: Select all

<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
<?php
mysql_connect('forbidden.example.com', 'username', 'password') or die(mysql_error());
?>
sanch3x
Forum Newbie
Posts: 2
Joined: Wed Jul 06, 2005 11:25 am

Post by sanch3x »

Wow, as simple as that...

Thanks a lot! :D
Post Reply