tmyonline Posted April 29, 2009 Share Posted April 29, 2009 Hi Guys, My Ajax works fine on my Window machine but when I uploaded it to the server, it failed. Below is the code on the server: <?php class Message { public $messOrder; public $subject; public $content; } ... $message = new Message(); $message->messOrder = $mailRow['messOrder']; ... print(json_encode($message)); ?> When debugging, I saw it complain "call to the undefined function json_encode()", the last line above. I don't get it. It works fine on my machine though. Any idea ? Thanks. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted April 29, 2009 Share Posted April 29, 2009 json_encode is available for php 5.2.0 and higher it's most likely not available because you are running a lower version of php. A work around i use is listed on the manual page and starts with if (!function_exists('json_encode')) Quote Link to comment Share on other sites More sharing options...
tmyonline Posted May 1, 2009 Author Share Posted May 1, 2009 Thanks Dj Kat. It may be it. I tried your work-around solution if (!function_exists('json_encode')) print(json_encode($message)); but it didn't work. Do you have a link to the manual page so I can find out more about it ? Thanks. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 No no, you got it mixed up. Think! if (function_exists('json_encode')) print(json_encode($message)); Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted May 1, 2009 Share Posted May 1, 2009 I didn't gave the code to the working solution it was a part of it so you would know what to look for. here is the link to the direct script http://nl2.php.net/manual/en/function.json-encode.php#82904 Quote Link to comment Share on other sites More sharing options...
tmyonline Posted May 6, 2009 Author Share Posted May 6, 2009 Thanks Dj Kat. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.