From 115054b0e9de5d664d75308d7f8cdf429ab40ad8 Mon Sep 17 00:00:00 2001 From: Thibault Le Meur Date: Thu, 1 Mar 2007 11:04:02 +0000 Subject: [PATCH] Added new db_tables_exist function and Fixed a missing-table bug when browsing result if the admin has deleted the token table git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2466 b72ed6b6-b9f8-46b5-92b4-906544132732 --- admin/browse.php | 3 ++- common.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/admin/browse.php b/admin/browse.php index 86633618faa..8f00ef33c50 100644 --- a/admin/browse.php +++ b/admin/browse.php @@ -555,7 +555,8 @@ if ($private == "N") { $SQL = "Select * FROM {$dbprefix}tokens_$surveyid WHERE token=?"; - if ($SQLResult = db_execute_assoc($SQL, $dtrow['token'])) + if ( db_tables_exist("{$dbprefix}tokens_$surveyid") && + $SQLResult = db_execute_assoc($SQL, $dtrow['token'])) { $TokenRow = $SQLResult->FetchRow(); } diff --git a/common.php b/common.php index f2f3e566dce..49ef2d16931 100644 --- a/common.php +++ b/common.php @@ -389,6 +389,27 @@ function db_select_tables_like($table) } } +/* + * Return a boolean stating if the table(s) exist(s) + * Accepts '%' in names since it uses the 'like' statement + */ +function db_tables_exist($table) +{ + global $connect; + + $surveyHasTokensTblQ = db_select_tables_like("$table"); + $surveyHasTokensTblResult = db_execute_num($surveyHasTokensTblQ); + + if ($surveyHasTokensTblResult->RecordCount() >= 1) + { + return TRUE; + } + else + { + return FALSE; + } +} + /** * getsurveylist() Queries the database (survey table) for a list of existing surveys * @global string $surveyid