Parsing error with JSON

I am using some coding from datatables - and yes a newbie,
I have problems with the data not being pulled and after some debugging, I have this error:

Parse error on line 1:
SSP: : simple($_GET,
Expecting '{', '['

I have attached the snippet of coding and have tried several syntax but can not seem to get it right. Long day.
I have also posted the coding from the entire page...
Could someone be as so kind as to help with it? Thank you...

echo json_encode(
	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )

Open in new window


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables

// DB table to use
$table = 'datatables_demo';
echo $table;

// Table's primary key
$primaryKey = 'id';
echo $primaryKey;

// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case object
// parameter names
$columns = array(
	array( 'db' => 'first_name', 'dt' => 'first_name' ),
	array( 'db' => 'last_name',  'dt' => 'last_name' ),
	array( 'db' => 'position',   'dt' => 'position' ),
	array( 'db' => 'office',     'dt' => 'office' ),
		'db'        => 'start_date',
		'dt'        => 'start_date',
		'formatter' => function( $d, $row ) {
			return date( 'jS M y', strtotime($d));
		'db'        => 'salary',
		'dt'        => 'salary',
		'formatter' => function( $d, $row ) {
			return '$'.number_format($d);

// SQL server connection information
$sql_details = array(
	'user' => 'root',
	'pass' => '1Lanceandme2',
	'db'   => 'testexample',
	'host' => '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.

require( 'ssp.class.php' );

echo json_encode(
	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
JSON_Encode() function expects a string, an array, or an object for input.  What is the value produced by this static method?

SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns );
OverthereAuthor Commented:
That's a good question! I should have dump the vars. Here are the results of doing so: ( I starred out the pass -didn't want to post that!)

Arrayarray(4) { ["user"]=> string(4) "root" ["pass"]=> string(12) "************" ["db"]=> string(11) "testexample" ["host"]=> string(9) "localhost" } array(0) { }
 {"error":"An error occurred while connecting to the database. The error reported by the server was: could not find driver"}

Open in new window

I have checked to ensure the drivers are installed by doing this: (and they did exist and I got my php info too.)
And I checked the php.ini too.  
I do not know what else to check - pathing problem ? but where?
Once again Ray, I am lost..sigh

if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
    echo 'We don\'t have mysqli!!!';
} else {
    echo 'Phew we have it!';



Open in new window

OverthereAuthor Commented:
Added note. I am using Web Matrix 3. One site uses Php 5.3 and it reports that it has mysqli.
The site that I am having problems with is set to use PHP 5.4 and says it DOESN'T have mysqli!
Each site can be set to a different language etc.
So, how do I fix that site that can not find the mysqli?
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Ray PaseurCommented:
It may be easier to work on this problem in pieces.  Here is what you need to know about MySQL / MySQLi conversion (why it had to happen, what you have to do to convert old programs for modern standards, etc...

Here is advice from MySQL about MySqLND:

My recommendation would be to get the MySQLi extension working and verified with a simple code example (almost any connection script shown in the article will be helpful to verify the installation).  Then come back to the issue about JSON.

Conceptually, JSON is just like XML - it's a formatted transport mechanism for data exchange between applications.  JSON turns complex data structures into character strings that can be send back and forth over APIs, etc.  In PHP it has some rudimentary error message capabilities, as shown in this code snippet.  If JSON is really the problem (incorrect formatting or truncated string) this may help tease out the errors.  Here is the URL:

Here is the PHP code, including a hard-wired JSON string:
<?php // demo/json_decode_show_errors.php
 * JSON stands for JavaScript Object Notation
 * JSON support in PHP does not have very good error handling
 * JSON strings are all UTF-8
 * PHP man page references
echo '<pre>';

$jso = <<<EOD
{"id":",2005:389903668427763712","objectType":"activity","actor":{"objectType":"person","id":"","link":"","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post","postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","link":""},"provider":{"objectType":"service","displayName":"Twitter","link":""},"link":"","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":",2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},"geo":{"type":"Point","coordinates":[31.99686058,-88.72688823]},"twitter_entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"twitter_filter_level":"medium","twitter_lang":"en","retweetCount":0,"gnip":{"matching_rules":[{"tag":null}],"language":{"value":"en"}}}

$obj = json_decode($jso);
if ($obj)
    $x = $obj->objectType;
    $y = $obj->actor->displayName;
    echo PHP_EOL . "$x $y" . PHP_EOL;

    // var_dump($obj);

if (!$obj) echo json_last_error_message();

function json_last_error_message()
    static $errors = array
    ( JSON_ERROR_NONE           => null
    , JSON_ERROR_DEPTH          => 'Maximum stack depth exceeded'
    , JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch'
    , JSON_ERROR_CTRL_CHAR      => 'Unexpected control character found'
    , JSON_ERROR_SYNTAX         => 'Syntax error, malformed JSON'
    , JSON_ERROR_UTF8           => 'Malformed UTF-8 characters, possibly incorrectly encoded'
    // ADD THESE AT PHP 5.5+ OR USE json_last_error_msg()
    if (defined('JSON_ERROR_RECURSION'))        $errors[JSON_ERROR_RECURSION]        = 'One or more recursive references in the value to be encoded';
    if (defined('JSON_ERROR_INF_OR_NAN'))       $errors[JSON_ERROR_INF_OR_NAN]       = 'One or more NAN or INF values in the value to be encoded';
    if (defined('JSON_ERROR_UNSUPPORTED_TYPE')) $errors[JSON_ERROR_UNSUPPORTED_TYPE] = 'A value of a type that cannot be encoded was given';

    $error = json_last_error();

    return array_key_exists($error, $errors)
    ? $errors[$error]
    : "Unknown error ({$error})"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OverthereAuthor Commented:
Thank you Ray -
I am going to try your coding and the advice....
I really like PHP, and gaining more experience with it and with the sometimes problems.
But a lot to learn yet.
I have a lot of experience with other languages (some arcade now -  ha ha!) and with XML processing (bunches!)
Right now, I am trying to resolve the pathing issue to the new installed version of PHP - it keeps showing the old version - boo! I think once that is resolved, its going to be easier.
Like eating an elephant - one bite at a time....
OverthereAuthor Commented:
as always good stuff from Ray!
Ray PaseurCommented:
Thanks for the points.  

This article may not be viewable yet, but you can bookmark it and come back in a day or two.  It's largely inspired by your question here, so it covers some of the ways of understanding XML and JSON - similarities and differences - with PHP and JavaScript code examples.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.