1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

New tracker needs PHP5.2 I have 5.1.6

Discussion in 'Keyword Tracker' started by tmf, Oct 14, 2009.

  1. #1
    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;
    }
     
    tmf, Oct 14, 2009 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    digitalpoint, Oct 14, 2009 IP
  3. tmf

    tmf Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I added

    if( !function_exists('json_decode') ) {
    function json_decode($data) {
    $json = new Services_JSON();
    return( $json->decode($data) );
    }
    }

    still no go.....

    R.
     
    tmf, Oct 14, 2009 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    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...
     
    digitalpoint, Oct 14, 2009 IP
  5. tmf

    tmf Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    <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.
     
    tmf, Oct 14, 2009 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    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.
     
    digitalpoint, Oct 14, 2009 IP
  7. freelistfool

    freelistfool Peon

    Messages:
    1,801
    Likes Received:
    101
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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):
     
    freelistfool, Oct 14, 2009 IP