JSON Parsing Error - Access Denied

JSON Parsing Error - Access Denied

MSAF_IncMSAF_Inc Posts: 4Questions: 0Answers: 0
edited September 2013 in General
View Error at: http://www.hunterpdx.com/metro_new_copy/view-reports-test.php

I am trying to integrate DataTables 1.9.4 into my site and have been working with the Server Side Processing, as the table is pulling from a pretty large database.

At any rate, I've gotten it to work beautifully when run locally on XAMPP! I have now uploaded the site live to my host server and am receiving a JSON Parsing Error:

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

I have reviewed the Network tab on Chrome's dev tools and I have managed to pinpoint the issue:

[quote]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[/quote]

It seems to me that the answer should be simple: either the username or password are incorrect. My confusion (and question) comes from the fact that it works great locally, but not live. I am using the same database connection information for multiple MySQL queries on my live site using a db.php file:
[code]
<?
/* Database Information - Required!! */
/* -- Configure the Variables Below --*/

$dbhost = 'localhost' ;
$dbusername = 'username';
$dbpasswd = 'password';
$database_name = 'database';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
[/code]

But for some reason it isn't accepting the same information from server_processing.php:

[code]
$gaSQL['user'] = "username";
$gaSQL['password'] = "password";
$gaSQL['db'] = "database";
$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 ' );
}
[/code]

The db.php database connection information works for all of my MySQL queries, but the same database connection information isn't working in server_processing.php! Can anyone tell me why? I'm new, but pretty handy at figuring things out...even a general direction on something else to look for would be greatly appreciated!

The page can be viewed at http://www.hunterpdx.com/metro_new_copy/view-reports-test.php

Thanks ahead of time!

Replies

  • MSAF_IncMSAF_Inc Posts: 4Questions: 0Answers: 0
    Capitalization inconsistencies - resolved by changing the variables gaSQL to gaSql.
This discussion has been closed.