diff --git a/js/tbl_chart.js b/js/tbl_chart.js index 1518f04ed4..23034a6a73 100644 --- a/js/tbl_chart.js +++ b/js/tbl_chart.js @@ -203,7 +203,11 @@ function drawChart() { $('select[name="chartXAxis"] option').each(function() { columnNames.push($(this).text()); }); - currentChart = PMA_queryChart(chart_data, columnNames, currentSettings); + try { + currentChart = PMA_queryChart(chart_data, columnNames, currentSettings); + } catch(err) { + PMA_ajaxShowMessage(err.message, false); + } } function getSelectedSeries() { diff --git a/tbl_chart.php b/tbl_chart.php index 04505abe7b..ebcccdceed 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -59,6 +59,12 @@ if (isset($_REQUEST['ajax_request']) } $response = PMA_Response::getInstance(); +// Throw error if no sql query is set +if(! isset($sql_query) || $sql_query == '') { + $response->isSuccess(false); + $response->addHTML(PMA_Message::error(__('No SQL query was set to fetch data.'))); + exit; +} $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('chart.js'); @@ -159,6 +165,7 @@ $htmlString = '