jasonflaherty
jasonflaherty

Reputation: 1944

Flat File Photo Rating Script Questions

I have a very limited server environment. I can't even use JSON. I have created a page with about 25 photos on it. When you roll over the photo a 5 star rating div appears, you can click on the stars you think the photo should be rated at.

I have looked online at some tutorials and what not and got a JSON version going, then put it on the server and blah... nothing. No JSON. Should have checked that huH? Well, I know I can write to text files, so I am going that route. I followed this tut: http://net.tutsplus.com/tutorials/html-css-techniques/building-a-5-star-rating-system-with-jquery-ajax-and-php/ to get it running on my images. Works just like it want it to... however, not on the server without JSON.

SO! What I want to know is, how can I make this write to a flat file? I can use the .POST{} jquery function and call a php script, but I am lost at how to post the data to the file.

Thanks for any thoughts, ideas, or the like. :)

Upvotes: 0

Views: 728

Answers (1)

webbiedave
webbiedave

Reputation: 48887

I've used json on PHP4 boxes. Simply use:

http://pear.php.net/package/Services_JSON/

Then, in your code do something along the lines of:

if (!function_exists('json_encode')) {
    require_once('services_json.php');
    $_JSON = new Services_JSON();

    function json_encode($value, $options = 0)
    {
        global $_JSON;
        return $_JSON->encode($value);
    }

    function json_decode($str, $assoc = false, $depth = 512)
    {
        global $_JSON;
        return $_JSON->decode($str);
    }
}

This has allowed me to use json_encode/decode functions without worrying about PHP version.

Upvotes: 1

Related Questions