Forum Moderators: coopster

Message Too Old, No Replies

I want to do an enemy detection script

How to query an enemy database

         

haryanto

5:05 pm on Feb 28, 2004 (gmt 0)

10+ Year Member



Hi guys,

I have a very stupid hypothetical php script that I want to do. I want to have the index.php to query the 2 servers to see if the name and the state of the visitor matches my enemy list which are mysql 2 identical databases in 2 separate servers.
I have 2 textboxes in the form which user input Name and State.

Say I have 3 servers. Server1 is the main server.
Server2 and server3 are database servers, server3 is backup server in case server2 goes down.

Server1:
index.php

Server2:
the database

Server3
the database

Database contents
------------------
¦ Name ¦ State ¦
------------------
¦ Chan ¦ Chicago ¦
------------------
¦ Mike ¦ Colorado ¦
------------------
¦ Alex ¦ Michigan ¦
------------------

What should I have in the index.php to query server2 first then if it is is down query server3,
If name and state matches,index.php spits out "$name from $state, you are an idiot!Can't believe you are still alive! Get out of my website you loser!" , If not, it will echo "Congratulations, you are not in the idiots list!"

jatar_k

6:18 pm on Feb 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What should I have in the index.php to query server2 first then if it is is down query server3

mysql_connect - Returns a MySQL link identifier on success, or FALSE on failure.

$dbh1=mysql_connect($server1, $user, $password);
if (!$dbh1) $dbh2=mysql_connect($server2, $user, $password);
if (!$dbh2) echo "both servers are down, too bad.";

haryanto

10:42 pm on Feb 28, 2004 (gmt 0)

10+ Year Member



But how do I query the database to check the name and state exist in the database? say if name is Chan but state is California then he will not be in the enemy list.

jatar_k

11:09 pm on Feb 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Maybe this will help
Basics of extracting data from MySQL using PHP [webmasterworld.com]