diff options
author | arun <arun@nubati.net> | 2006-12-07 11:15:53 +0000 |
---|---|---|
committer | arun <arun> | 2006-12-07 11:15:53 +0000 |
commit | 987f4b37750c1c4c6d414a3cb8ae5e7b798fe41a (patch) | |
tree | 68673aab902f6790ec050540b1c43d3f6339434b | |
parent | c997188d74716ef29f82da903435b95eec736d79 (diff) | |
download | e-DoKo-987f4b37750c1c4c6d414a3cb8ae5e7b798fe41a.tar.gz e-DoKo-987f4b37750c1c4c6d414a3cb8ae5e7b798fe41a.tar.bz2 e-DoKo-987f4b37750c1c4c6d414a3cb8ae5e7b798fe41a.zip |
tables seems to be case sensitive on dreamhost...fixed it
-rw-r--r-- | create_database.sql | 1 | ||||
-rw-r--r-- | db.php | 62 | ||||
-rw-r--r-- | functions.php | 2 | ||||
-rw-r--r-- | index.php | 18 |
4 files changed, 42 insertions, 41 deletions
diff --git a/create_database.sql b/create_database.sql index 9156bae..b6e7332 100644 --- a/create_database.sql +++ b/create_database.sql @@ -72,6 +72,7 @@ CREATE TABLE `Game` ( `randomnumbers` varchar(136) default NULL, `type` enum('solo','wedding','poverty','dpoverty') default NULL, `solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL, + `status` enum('pre','play','gameover') default NULL, `id` int(11) NOT NULL auto_increment, UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -7,8 +7,8 @@ function DB_open() { global $DB; - if ( $DB = mysql_connect('localhost','dokodb', 'doko') ) - mysql_select_db('doko') or die('Could not select database'); + if ( $DB = mysql_connect('mysql.nubati.net','doko', '$DoKo#.') ) + mysql_select_db('dokodb') or die('Could not select database'); else die (mysql_error()); @@ -38,7 +38,7 @@ function DB_quote_smart($value) function DB_test() { - $result = mysql_query("SELECT * FROM user"); + $result = mysql_query("SELECT * FROM User"); while($r = mysql_fetch_array($result,MYSQL_NUM)) { foreach($r as $thing) @@ -51,7 +51,7 @@ function DB_test() function DB_get_email_by_name($name) { echo "*looking for $name*"; - $result = mysql_query("SELECT email FROM user WHERE fullname=".DB_quote_smart($name).""); + $result = mysql_query("SELECT email FROM User WHERE fullname=".DB_quote_smart($name).""); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -62,7 +62,7 @@ function DB_get_email_by_name($name) function DB_get_userid_by_name($name) { - $result = mysql_query("SELECT id FROM user WHERE fullname=".DB_quote_smart($name)); + $result = mysql_query("SELECT id FROM User WHERE fullname=".DB_quote_smart($name)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -72,7 +72,7 @@ function DB_get_userid_by_name($name) } function DB_get_userid_by_passwd($passwd) { - $result = mysql_query("SELECT id FROM user WHERE password=".DB_quote_smart($passwd)); + $result = mysql_query("SELECT id FROM User WHERE password=".DB_quote_smart($passwd)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -82,7 +82,7 @@ function DB_get_userid_by_passwd($passwd) } function DB_get_userid_by_email($email) { - $result = mysql_query("SELECT id FROM user WHERE email=".DB_quote_smart($email)); + $result = mysql_query("SELECT id FROM User WHERE email=".DB_quote_smart($email)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -93,7 +93,7 @@ function DB_get_userid_by_email($email) function DB_get_handid_by_hash($hash) { - $result = mysql_query("SELECT id FROM hand WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT id FROM Hand WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -104,7 +104,7 @@ function DB_get_handid_by_hash($hash) function DB_get_userid_by_hash($hash) { - $result = mysql_query("SELECT user_id FROM hand WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT user_id FROM Hand WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -115,7 +115,7 @@ function DB_get_userid_by_hash($hash) function DB_get_pos_by_hash($hash) { - $result = mysql_query("SELECT position FROM hand WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT position FROM Hand WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -126,7 +126,7 @@ function DB_get_pos_by_hash($hash) function DB_get_name_by_hash($hash) { - $result = mysql_query("SELECT fullname FROM hand LEFT JOIN user ON hand.user_id=user.id WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT fullname FROM Hand LEFT JOIN User ON hand.user_id=user.id WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -137,7 +137,7 @@ function DB_get_name_by_hash($hash) function DB_get_status_by_hash($hash) { - $result = mysql_query("SELECT status FROM hand WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT status FROM Hand WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -148,13 +148,13 @@ function DB_get_status_by_hash($hash) function DB_set_hand_status_by_hash($hash,$status) { - mysql_query("UPDATE hand SET status='".$status."' WHERE hash=".DB_quote_smart($hash)); + mysql_query("UPDATE Hand SET status='".$status."' WHERE hash=".DB_quote_smart($hash)); return; } function DB_get_gameid_by_hash($hash) { - $result = mysql_query("SELECT game_id FROM hand WHERE hash=".DB_quote_smart($hash)); + $result = mysql_query("SELECT game_id FROM Hand WHERE hash=".DB_quote_smart($hash)); $r = mysql_fetch_array($result,MYSQL_NUM); if($r) @@ -171,25 +171,25 @@ function DB_cancel_game($hash) return; /* get the IDs of all players */ - $result = mysql_query("SELECT id FROM hand WHERE game_id=".DB_quote_smart($gameid)); + $result = mysql_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid)); while($r = mysql_fetch_array($result,MYSQL_NUM)) { $id = $r[0]; - $tmp = mysql_query("SELECT id FROM hand_card WHERE hand_id=".DB_quote_smart($id)); + $tmp = mysql_query("SELECT id FROM Hand_Card WHERE hand_id=".DB_quote_smart($id)); $tmp = mysql_fetch_array($tmp,MYSQL_NUM); - mysql_query("DELETE FROM play WHERE hand_card_id=".DB_quote_smart($tmp[0])); + mysql_query("DELETE FROM Play WHERE hand_card_id=".DB_quote_smart($tmp[0])); - mysql_query("DELETE FROM hand_card WHERE hand_id=".DB_quote_smart($id)); - mysql_query("DELETE FROM score WHERE hand_id=".DB_quote_smart($id)); - mysql_query("DELETE FROM hand WHERE id=".DB_quote_smart($id)); + mysql_query("DELETE FROM Hand_Card WHERE hand_id=".DB_quote_smart($id)); + mysql_query("DELETE FROM Score WHERE hand_id=".DB_quote_smart($id)); + mysql_query("DELETE FROM Hand WHERE id=".DB_quote_smart($id)); } /* delete game */ - mysql_query("DELETE FROM user_game_prefs WHERE game_id=".DB_quote_smart($gameid)); - mysql_query("DELETE FROM trick WHERE game_id=".DB_quote_smart($gameid)); - mysql_query("DELETE FROM game WHERE id=".DB_quote_smart($gameid)); + mysql_query("DELETE FROM User_Game_Prefs WHERE game_id=".DB_quote_smart($gameid)); + mysql_query("DELETE FROM Trick WHERE game_id=".DB_quote_smart($gameid)); + mysql_query("DELETE FROM Game WHERE id=".DB_quote_smart($gameid)); return; } @@ -200,7 +200,7 @@ function DB_get_hand($me) $handid = DB_get_handid_by_hash($me); - $result = mysql_query("SELECT card_id FROM hand_card WHERE hand_id=".DB_quote_smart($handid)." and played='false' "); + $result = mysql_query("SELECT card_id FROM Hand_Card WHERE hand_id=".DB_quote_smart($handid)." and played='false' "); while($r = mysql_fetch_array($result,MYSQL_NUM)) $cards[]=$r[0]; @@ -209,20 +209,20 @@ function DB_get_hand($me) function DB_set_solo_by_hash($me,$solo) { - mysql_query("UPDATE hand SET solo=".DB_quote_smart($solo)." WHERE hash=".DB_quote_smart($hash)); + mysql_query("UPDATE Hand SET solo=".DB_quote_smart($solo)." WHERE hash=".DB_quote_smart($hash)); return; } function DB_set_sickness_by_hash($me,$sickness) { - mysql_query("UPDATE hand SET sickness=".DB_quote_smart($sickness)." WHERE hash=".DB_quote_smart($hash)); + mysql_query("UPDATE Hand SET sickness=".DB_quote_smart($sickness)." WHERE hash=".DB_quote_smart($hash)); return; } function DB_get_current_trickid($gameid) { - $result = mysql_query("SELECT trick.id,MAX(play.sequence) FROM play ". - "LEFT JOIN trick ON play.trick_id=trick.id ". + $result = mysql_query("SELECT trick.id,MAX(play.sequence) FROM Play ". + "LEFT JOIN Trick ON play.trick_id=trick.id ". "WHERE trick.game_id=".DB_quote_smart($gameid)." ". "GROUP BY trick.id"); while( $r = mysql_fetch_array($result,MYSQL_NUM) ) @@ -233,7 +233,7 @@ function DB_get_current_trickid($gameid) if(!$sequence || $sequence==4) { - mysql_query("INSERT INTO trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).")"); + mysql_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).")"); $trickid = mysql_insert_id(); $sequence = 1; } @@ -247,7 +247,7 @@ function DB_get_current_trickid($gameid) function DB_get_max_trickid($gameid) { - $result = mysql_query("SELECT MAX(id) FROM trick WHERE game_id=".DB_quote_smart($gameid)); + $result = mysql_query("SELECT MAX(id) FROM Trick WHERE game_id=".DB_quote_smart($gameid)); $r = mysql_fetch_array($result,MYSQL_NUM) ; @@ -256,7 +256,7 @@ function DB_get_max_trickid($gameid) function DB_play_card($trickid,$handcardid,$sequence) { - mysql_query("INSERT into play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid). + mysql_query("INSERT INTO Play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid). ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")"); return; } diff --git a/functions.php b/functions.php index 0ce10e2..a52ad7a 100644 --- a/functions.php +++ b/functions.php @@ -4,7 +4,7 @@ * config */ -$host = "http://doko.nubati.net/index.php"; +$host = "http://doko.nubati.net/database/index.php"; $wiki = "http://wiki.nubati.net/index.php?title=EmailDoko"; $debug = 1; @@ -96,7 +96,7 @@ else if( isset($_REQUEST["PlayerA"]) && $randomNRstring = join(":",$randomNR); /* create game */ - mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL, NULL)"); + mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre', NULL)"); $game_id = mysql_insert_id(); @@ -288,11 +288,11 @@ else if(isset($_REQUEST["me"])) " play.sequence as sequence, ". " hand.hash as hash, ". " trick.id ". - "FROM trick ". - "LEFT JOIN play ON trick.id=play.trick_id ". - "LEFT JOIN hand_card ON play.hand_card_id=hand_card.id ". - "LEFT JOIN hand ON hand_card.hand_id=hand.id ". - "LEFT JOIN user ON user.id=hand.user_id ". + "FROM Trick ". + "LEFT JOIN Play ON trick.id=play.trick_id ". + "LEFT JOIN Hand_Card ON play.hand_card_id=hand_card.id ". + "LEFT JOIN Hand ON hand_card.hand_id=hand.id ". + "LEFT JOIN User ON user.id=hand.user_id ". "WHERE trick.game_id='".$gameid."' ". "ORDER BY trick.id,sequence ASC"); @@ -390,13 +390,13 @@ else if(isset($_REQUEST["me"])) /* check if we have card */ /* set played in hand_card to true where hand_id and card_id*/ - $result = mysql_query("SELECT id from hand_card WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card)); + $result = mysql_query("SELECT id FROM Hand_Card WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card)); $r = mysql_fetch_array($result,MYSQL_NUM); $handcardid = $r[0]; if($handcardid) { - mysql_query("UPDATE hand_card SET played='true' WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card)); + mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card)); /* get trick id or start new trick */ $a = DB_get_current_trickid($gameid); @@ -527,7 +527,7 @@ else if(isset($_REQUEST["Rfullname"]) && } if($ok) { - $r=mysql_query("INSERT INTO user VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]). + $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]). ",".DB_quote_smart($_REQUEST["Remail"]). ",".DB_quote_smart(md5($_REQUEST["Rpassword"])). ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); |