Skip to content

Commit

Permalink
Added new db_tables_exist function and Fixed a missing-table bug when…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Thibault Le Meur committed Mar 1, 2007
1 parent fb02b1d commit 115054b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion admin/browse.php
Expand Up @@ -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();
}
Expand Down
21 changes: 21 additions & 0 deletions common.php
Expand Up @@ -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
Expand Down

0 comments on commit 115054b

Please sign in to comment.