Can anything be done to replace the one function that is not supported in 5.1.6? I tried to replace it with another function but did not work. Its the json_decode function, I found this the code below and replaced it but did not work. if ( !function_exists('json_decode') ){ function json_decode($json) { $comment = false; $out = '$x='; for ($i=0; $i<strlen($json); $i++) { if (!$comment) { if ($json[$i] == '{') $out .= ' array('; else if ($json[$i] == '}') $out .= ')'; else if ($json[$i] == ':') $out .= '=>'; else $out .= $json[$i]; } else $out .= $json[$i]; if ($json[$i] == '"') $comment = !$comment; } eval($out . ';'); return $x; }
You could probably include the JSON.php class file that this guy did to mimic the functionality... http://abeautifulsite.net/notebook/71
I added if( !function_exists('json_decode') ) { function json_decode($data) { $json = new Services_JSON(); return( $json->decode($data) ); } } still no go..... R.
More to it than just that. According to those instructions, you need to download this: http://download.pear.php.net/package/Services_JSON-1.0.1.tgz From that, get the JSON.php file, and put it in the same directory as your advanced usage script. Add this to the advanced usage script after the <?php line: include ('JSON.php'); if( !function_exists('json_decode') ) { function json_decode($data) { $json = new Services_JSON(); return( $json->decode($data) ); } } PHP: That should (hopefully) work...
<br /> <b>Fatal error</b>: Cannot use object of type stdClass as array in <b>/var/www/vhosts/themindfactory.com/httpdocs/my.php</b> on line <b>78</b><br /> Not sure what this means.... seems the output of the function can not be used. R.
Sorry, not really sure... I don't have any PHP installations running old versions of PHP to test anything on. I was just going on what that webpage said.
I got it to work in php 5.1.6 by saving this file http://mike.teczno.com/JSON/JSON.phps as JSON.php in the same directory as the Advanced Usage Script (new php script necessary on my server for the new keyword tracker). Then adding this code to the top of the Advanced Usage Script. if ( !function_exists('json_decode') ){ function json_decode($content, $assoc){ require_once 'JSON.php'; if ( $assoc ){ $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); } else { $json = new Services_JSON; } return $json->decode($content); } } Code (markup):