From f1f38bd725159b496879a05a872a293070aed33e Mon Sep 17 00:00:00 2001 From: Leander Date: Tue, 4 Apr 2017 11:23:03 +0200 Subject: [PATCH] T201704041122 --- Config.txt | 1 + Database.php | 2 ++ answer.php | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Config.txt b/Config.txt index d68a424..badc21f 100644 --- a/Config.txt +++ b/Config.txt @@ -19,3 +19,4 @@ 13101 - User ID not specified 13102 - No valid time specified 13103 - No chosen answer specified +13104 - No game for specified user diff --git a/Database.php b/Database.php index 2c378b0..b3ff83c 100644 --- a/Database.php +++ b/Database.php @@ -72,6 +72,8 @@ class Database return 'No valid time specified. This is an internal error.'; case 13103: return 'No chosen answer specified. This is an internal error.'; + case 13104: + return 'No game for specified user name. This is an internal error.'; default: return 'An unknown error occurred.'; } diff --git a/answer.php b/answer.php index 94163b8..a2282ac 100644 --- a/answer.php +++ b/answer.php @@ -25,7 +25,6 @@ $correct_answer = $db->query('SELECT "current_right_answer" FROM "Games" WHERE "ID" = $1', array($uid)) ['data'][0]['current_right_answer']; - print_r(pg_last_error()); $correct = $correct_answer == $chosen_answer ? true : false; $score = $correct_answer == $chosen_answer ? calculate_points($time) : 0; if($uid == '') { @@ -34,6 +33,9 @@ $error = 13102; } else if($chosen_answer == -1) { $error = 13103; + } else if($db->query('SELECT EXISTS (SELECT 1 FROM "Games" WHERE "ID" = $1)', array($uid))['data'][0]['exists'] == 'f') { + $error = 13104; + print 'no game'; } else { // points in table }