本文整理汇总了PHP中PMA_SQP_getErrorString函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_SQP_getErrorString函数的具体用法?PHP PMA_SQP_getErrorString怎么用?PHP PMA_SQP_getErrorString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_SQP_getErrorString函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParser
/**
* Testing of SQL parser.
*
* @param string $sql SQL query to parse
* @param array $expected Expected parse result
* @param string $error Expected error message
*
* @return void
*
* @dataProvider parserData
* @group medium
*/
public function testParser($sql, $expected, $error = '')
{
PMA_SQP_resetError();
$parsed_sql = PMA_SQP_parse($sql);
$this->assertEquals($error, PMA_SQP_getErrorString());
$this->assertEquals($expected, $parsed_sql);
}
示例2: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <table border="0" cellpadding="2" cellspacing="1">' . ' <tr>' . "\n" . ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td>';
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n";
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('Reference', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="middle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p></div>' . "\n";
}
// end if
$tmp_mysql_error = '';
// for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message);
// save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n" . ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mk.keck
if (substr($error_message, 1, 4) == '1062') {
// TODO: do not assume that the error message is in English
// and do not use mysql_result()
// explode the entry and the column
$arr_mysql_val_key = explode('entry \'', $tmp_mysql_error);
$arr_mysql_val_key = explode('\' for key', $arr_mysql_val_key[1]);
// get the duplicate value
$string_duplicate_val = trim(strtolower($arr_mysql_val_key[0]));
// get the field name ...
$string_duplicate_key = mysql_result(mysql_query("SHOW FIELDS FROM " . $table), $arr_mysql_val_key[1] - 1, 0);
//.........这里部分代码省略.........
示例3: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string $error_message the error message
* @param string $the_query the sql query that failed
* @param bool $is_modify_link whether to show a "modify" link or not
* @param string $back_url the "back" link url (full path is not required)
* @param bool $exit EXIT the page?
*
* @global string the curent table
* @global string the current db
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $table, $db;
/**
* start http output, display html headers
*/
include_once './libraries/header.inc.php';
$error_msg_output = '';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$formatted_sql = htmlspecialchars(substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
}
// ---
$error_msg_output .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
$error_msg_output .= ' <div class="error"><h1>' . __('Error') . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
$error_msg_output .= PMA_SQP_getErrorString() . "\n";
$error_msg_output .= '<br />' . "\n";
}
// ---
// modified to show the help on sql errors
$error_msg_output .= ' <p><strong>' . __('SQL query') . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
$error_msg_output .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link) {
$_url_params = array('sql_query' => $the_query, 'show_query' => 1);
if (strlen($table)) {
$_url_params['db'] = $db;
$_url_params['table'] = $table;
$doedit_goto = '<a href="tbl_sql.php' . PMA_generate_common_url($_url_params) . '">';
} elseif (strlen($db)) {
$_url_params['db'] = $db;
$doedit_goto = '<a href="db_sql.php' . PMA_generate_common_url($_url_params) . '">';
} else {
$doedit_goto = '<a href="server_sql.php' . PMA_generate_common_url($_url_params) . '">';
}
$error_msg_output .= $doedit_goto . PMA_getIcon('b_edit.png', __('Edit')) . '</a>';
}
// end if
$error_msg_output .= ' </p>' . "\n" . ' <p>' . "\n" . ' ' . $formatted_sql . "\n" . ' </p>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show the help on error-returns
// (now error-messages-server)
$error_msg_output .= '<p>' . "\n" . ' <strong>' . __('MySQL said: ') . '</strong>' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping,
// we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
$error_msg_output .= '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
$error_msg_output .= '</div>';
$_SESSION['Import_message']['message'] = $error_msg_output;
if ($exit) {
/**
* If in an Ajax request
* - avoid displaying a Back link
* - use PMA_ajaxResponse() to transmit the message and exit
//.........这里部分代码省略.........
示例4: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @uses footer.inc.php
* @uses header.inc.php
* @uses $GLOBALS['sql_query']
* @uses $GLOBALS['strError']
* @uses $GLOBALS['strSQLQuery']
* @uses $GLOBALS['pmaThemeImage']
* @uses $GLOBALS['strEdit']
* @uses $GLOBALS['strMySQLSaid']
* @uses $GLOBALS['cfg']['PropertiesIconic']
* @uses $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
* @uses PMA_backquote()
* @uses PMA_DBI_getError()
* @uses PMA_formatSql()
* @uses PMA_generate_common_hidden_inputs()
* @uses PMA_generate_common_url()
* @uses PMA_showMySQLDocu()
* @uses PMA_sqlAddslashes()
* @uses PMA_SQP_isError()
* @uses PMA_SQP_parse()
* @uses PMA_SQP_getErrorString()
* @uses strtolower()
* @uses urlencode()
* @uses str_replace()
* @uses nl2br()
* @uses substr()
* @uses preg_replace()
* @uses preg_match()
* @uses explode()
* @uses implode()
* @uses is_array()
* @uses function_exists()
* @uses htmlspecialchars()
* @uses trim()
* @uses strstr()
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global string the curent table
* @global string the current db
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $table, $db;
/**
* start http output, display html headers
*/
require_once './libraries/header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$formatted_sql = substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString() . "\n";
echo '<br />' . "\n";
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link && strlen($db)) {
if (strlen($table)) {
$doedit_goto = '<a href="tbl_sql.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
//.........这里部分代码省略.........
示例5: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $cfg, $table, $db, $sql_query;
require_once './libraries/header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString() . "\n";
echo '<br />' . "\n";
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img class="icon" src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo ' </p>' . "\n" . ' <p>' . "\n" . ' ' . $formatted_sql . "\n" . ' </p>' . "\n";
}
// end if
$tmp_mysql_error = '';
// for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message);
// save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
// (now error-messages-server)
echo '<p>' . "\n" . ' <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mkkeck
// 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry
// get table name
// TODO: what would be the best delimiter, while avoiding
// special characters that can become high-ascii after editing,
// depending upon which editor is used by the developer?
//.........这里部分代码省略.........
示例6: mysqlDie
/**
* Displays a MySQL error message in the main panel when $exit is true.
* Returns the error message otherwise.
*
* @param string|bool $error_message the error message
* @param string $the_query the sql query that failed
* @param bool $is_modify_link whether to show a "modify" link or not
* @param string $back_url the "back" link url (full path is not
* required)
* @param bool $exit EXIT the page?
*
* @return string
*
* @global string $table the curent table
* @global string $db the current db
*
* @access public
*/
public static function mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $table, $db;
$error_msg = '';
if (!$error_message) {
$error_message = $GLOBALS['dbi']->getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
$formatted_sql = self::formatSql($the_query, true);
}
// ---
$error_msg .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
$error_msg .= ' <div class="error"><h1>' . __('Error') . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !mb_strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
$error_msg .= PMA_SQP_getErrorString() . "\n";
$error_msg .= '<br />' . "\n";
}
// ---
// modified to show the help on sql errors
$error_msg .= '<p><strong>' . __('SQL query:') . '</strong>' . "\n";
$formattedSqlToLower = mb_strtolower($formatted_sql);
if (mb_strstr($formattedSqlToLower, 'select')) {
// please show me help to the error on select
$error_msg .= self::showMySQLDocu('SELECT');
}
if ($is_modify_link) {
$_url_params = array('sql_query' => $the_query, 'show_query' => 1);
if (mb_strlen($table)) {
$_url_params['db'] = $db;
$_url_params['table'] = $table;
$doedit_goto = '<a href="tbl_sql.php' . PMA_URL_getCommon($_url_params) . '">';
} elseif (mb_strlen($db)) {
$_url_params['db'] = $db;
$doedit_goto = '<a href="db_sql.php' . PMA_URL_getCommon($_url_params) . '">';
} else {
$doedit_goto = '<a href="server_sql.php' . PMA_URL_getCommon($_url_params) . '">';
}
$error_msg .= $doedit_goto . self::getIcon('b_edit.png', __('Edit')) . '</a>';
}
// end if
$error_msg .= ' </p>' . "\n" . '<p>' . "\n" . $formatted_sql . "\n" . '</p>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show the help on error-returns
// (now error-messages-server)
$error_msg .= '<p>' . "\n" . ' <strong>' . __('MySQL said: ') . '</strong>' . self::showMySQLDocu('Error-messages-server') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping,
// we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace line breaks
$error_message = nl2br($error_message);
$error_msg .= '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
$error_msg .= '</div>';
$_SESSION['Import_message']['message'] = $error_msg;
if (!$exit) {
return $error_msg;
}
/**
* If in an Ajax request
* - avoid displaying a Back link
* - use PMA_Response() to transmit the message and exit
*/
//.........这里部分代码省略.........
示例7: assertParser
private function assertParser($sql, $expected, $error = '')
{
$parsed_sql = PMA_SQP_parse($sql);
$this->assertEquals(PMA_SQP_getErrorString(), $error);
$this->assertEquals($parsed_sql, $expected);
}
示例8: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error mesage
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_mysql_error();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo '<p><b>' . $GLOBALS['strError'] . '</b></p>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
echo '<p>' . "\n";
echo ' ' . $GLOBALS['strSQLQuery'] . ' : ' . "\n";
if ($is_modify_link && isset($db)) {
echo ' [' . '<a href="db_details.php?' . PMA_generate_common_url($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=1">' . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
echo '<p>' . "\n" . ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br /><br />' . "\n";
echo PMA_showMySQLDocu('Error-returns', 'Error-returns');
if (!empty($back_url) && $exit) {
echo ' · [<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '">' . $GLOBALS['strBack'] . '</a>]';
}
echo "\n";
if ($exit) {
require_once './footer.inc.php';
}
}
示例9: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error mesage
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <table border="0" cellpadding="2" cellspacing="1">' . ' <tr>' . "\n" . ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td>';
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n";
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('Reference', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="absmiddle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p></div>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n" . ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br /><br />' . "\n";
echo '</div>';
if (!empty($back_url) && $exit) {
$goto_back_url = '<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '"> ';
echo ' </td> ' . "\n" . ' </tr>' . "\n" . ' <tr><td class="tblHeaders" align="center">';
echo '[' . $goto_back_url . $GLOBALS['strBack'] . ' </a>]';
}
echo ' </td>' . "\n" . ' </tr>' . "\n" . ' </table>' . "\n\n";
if ($exit) {
require_once './footer.inc.php';
}
}