mysql - 数据表 JSON 解析错误 - 访问被拒绝

标签 mysql json datatables

好的,我会尽量简明扼要。

错误可以在 http://www.hunterpdx.com/metro_new_copy/view-reports-test.php 处看到.

我在本地使用 DataTables-1.9.4,一切正常,但是一旦上传到我的主机服务器,我就会收到非常流行的 JSON 解析错误:

DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.

我在这里阅读了很多这些内容,并找到了很多很好的建议;主要是如何定位问题。我查看了 Chrome 开发工具上的“网络”选项卡,确定问题很简单:

Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'username'@'localhost' (using password: NO) in /home/metros9/public_html/hunterpdx.com/metro_new_copy/server_processing.php on line 50

Warning: Cannot modify header information - headers already sent by (output started at /home/metros9/public_html/hunterpdx.com/metro_new_copy/server_processing.php:50) in /home/metros9/public_html/hunterpdx.com/metro_new_copy/server_processing.php on line 42 Could not open connection to server

在我看来,答案应该很简单:用户名或密码不正确。我的困惑(和问题)来自于它在本地运行良好,但不能实时运行。我使用 db.php 文件在我的实时站点上对多个 MySQL 查询使用相同的数据库连接信息,但由于某种原因,它不接受来自 server_processing.php 的相同信息。谁能告诉我为什么?我是新人,但很擅长解决问题......即使是关于其他要寻找的东西的一般方向也会非常感激!

服务器处理.php

/* 数据库连接信息 */

$gaSQL['user']       = "*****";
$gaSQL['password']   = "*****";
$gaSQL['db']         = "*****";
$gaSQL['server']     = "localhost";



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP server-side, there is
 * no need to edit below this line
 */

/* 
 * Local functions
 */
function fatal_error ( $sErrorMessage = '' )
{
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( $sErrorMessage );
}


/* 
 * MySQL connection
 */
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) )
{
    fatal_error( 'Could not open connection to server' );
}

if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
    fatal_error( 'Could not select database ' );
}

最佳答案

变量被设置为 gaSQL,然后被称为 gaSql - 大小写不一致!

知道这很容易,但后悔花了多长时间才看到答案。

关于mysql - 数据表 JSON 解析错误 - 访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19063918/

相关文章:

php - 在 PHP 中到处使用准备好的语句? (PDO)

php - 在 php/mysql 中导入 SCORM 包

MySQL语句错误使用 'Limit'

javascript - 在 Jade 中渲染 JSON 对象名称

javascript - 从数据表中的自定义选择字段发送自定义数据

php - 担心表格字段太多

css - 在 netlify css 上部署失败 ./node_modules/gatsby/node_modules/css-loader

java - 在 java 中使用 JSON 到 bitbucket 服务器的 HTTP POST 返回 400 作为响应代码

javascript - 渲染大表的性能问题

javascript - jquery datatable - 设置列宽和换行文本