From 8901180d8598ecb90b33f872b80d1b9c6832ade5 Mon Sep 17 00:00:00 2001 From: Leander Date: Mon, 27 Mar 2017 15:58:06 +0200 Subject: [PATCH] T1703271557 --- Config.txt | 3 ++- Database.php | 4 ++-- start.php | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Config.txt b/Config.txt index d319ec4..6f058b0 100644 --- a/Config.txt +++ b/Config.txt @@ -10,4 +10,5 @@ 11102 - User name already exists = start.php = -12101 - More questions wanted then existing \ No newline at end of file +12101 - 0 questions wanted, no game without a question! +12102 - More questions wanted then existing \ No newline at end of file diff --git a/Database.php b/Database.php index 5dd804c..ba051fd 100644 --- a/Database.php +++ b/Database.php @@ -51,12 +51,12 @@ class Database case 11102: return 'User name already exists. Please pick a different name.'; case 12101: + return 'A game without a question is not possible. Please select new game length.'; + case 12102: return 'We only have '.$values[0].' questions. Please select new game length.'; default: return 'An unknown error occurred.'; } } - } - ?> \ No newline at end of file diff --git a/start.php b/start.php index c7f250c..e0279fb 100644 --- a/start.php +++ b/start.php @@ -14,9 +14,11 @@ $length = ($_GET['length'] && gettype(+$_GET['length']) == 'integer') ? +$_GET['length'] : 10; $database = new Database(); $questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count']; - - if($length > $questions_count) { + if($length = 0) { $error = 12101; + } + if($length > $questions_count) { + $error = 12102; $values = array($questions_count); } $response = Database::create_response($data, $error, $values);