Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSON Encoding problem breaks calendar

Posted on 2013-12-03
13
Medium Priority
?
563 Views
Last Modified: 2013-12-23
I have a calendar ('Fullcalendar'), which displays the reservations in our B&B. Suddenly the reservations in july and september are not displayed anymore (They are still in the db of Drupal)
My log gives two relevant messages:
         (1)Notice: Trying to get property of non-object in BookingEvent->formatJson() (line230 van /storage/web/public/sites/www.slapeninyerseke.nl/sites/all/modules/rooms/modules/rooms_availability/includes/rooms_availability.booking_event.inc).
        (2)Warning: json_encode(): Invalid UTF-8 sequence in argument in drupal_json_encode() (regel 4997 van /storage/web/public/sites/www.slapeninyerseke.nl/includes/common.inc).

From what I find on the net this has to do with the fact(???) that Mysql uses utf-8, but that my calendar data stream is apparently different. My log displays the data as a text file as they are supposed to appear in the calendar, but I cannot find any strange characters there. See for yourself:

[{"id":"1","start":"2013-07-01T13:00:00Z","end":"2013-07-03T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-154","start":"2013-07-04T13:00:00Z","end":"2013-07-04T13:00:00Z","title":"Franci...","color":"#4F1800"},{"id":"1","start":"2013-07-05T13:00:00Z","end":"2013-07-05T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-149","start":"2013-07-06T13:00:00Z","end":"2013-07-06T13:00:00Z","title":"Willy ...","color":"#4F1800"},{"id":"1","start":"2013-07-07T13:00:00Z","end":"2013-07-07T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-157","start":"2013-07-08T13:00:00Z","end":"2013-07-08T13:00:00Z","title":"G.Char...","color":"#4F1800"},{"id":"1","start":"2013-07-09T13:00:00Z","end":"2013-07-09T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-156","start":"2013-07-10T13:00:00Z","end":"2013-07-10T13:00:00Z","title":"Vander...","color":"#4F1800"},{"id":"1","start":"2013-07-11T13:00:00Z","end":"2013-07-14T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-160","start":"2013-07-15T13:00:00Z","end":"2013-07-17T13:00:00Z","title":"Mw. Fiers","color":"#4F1800"},{"id":"1","start":"2013-07-18T13:00:00Z","end":"2013-07-18T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-167","start":"2013-07-19T13:00:00Z","end":"2013-07-20T13:00:00Z","title":"Meeus","color":"#4F1800"},{"id":"1","start":"2013-07-21T13:00:00Z","end":"2013-07-22T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-172","start":"2013-07-23T13:00:00Z","end":"2013-07-23T13:00:00Z","title":"Onbeke...","color":"#4F1800"},{"id":"1","start":"2013-07-24T13:00:00Z","end":"2013-07-25T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"},{"id":"-145","start":"2013-07-26T13:00:00Z","end":"2013-07-26T13:00:00Z","title":"H.J. M...","color":"#4F1800"},{"id":"-176","start":"2013-07-27T13:00:00Z","end":"2013-07-27T13:00:00Z","title":null,"color":"#4F1800"},{"id":"1","start":"2013-07-28T13:00:00Z","end":"2013-07-31T13:00:00Z","title":"AV","color":"#8CBF62","borderColor":"#04711B"}]

Open in new window


It appears I need to do some conversion from or to UTF, but I have no idea. Please help.

Thanks

Theo Richel
0
Comment
Question by:TheoRichel
  • 7
  • 6
13 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39693705
You may want to start by understanding character encoding.  This article should help.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html

In the instant case, the data being fed to JSON_encode is not valid UTF-8.  You would want to find out where this data comes from.  The Notice about "Trying to get property of non-object" is almost certainly an artifact of an encoding or decoding error.
0
 

Author Comment

by:TheoRichel
ID: 39693752
Allright Ill read that piece. Thanks
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39693977
Also, check the notes here.  You may be able to get JSON to tell you what's wrong.  in my experience the error messages were not particularly useful, but a little bit better than nothing.
http://php.net/manual/en/function.json-last-error.php
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:TheoRichel
ID: 39694226
Thanks very much. I'll get back.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39694252
We'll be here and will do our best to help!
0
 

Author Comment

by:TheoRichel
ID: 39695258
I have read your piece and find it very informative, though I wouldnt know how to execute the scripts you provide. I have also tried to install a Drupal module ('Php-error') which is supposed to tell me where the problem is, but I should install the PHP-error library for that and according to the readme only an idiot does that on a production site. As I am not an idiot and this is a production site, I havent progressed much.

I can see the datastream that the calendar apparently refuses, but I wouldnt know how to make the datastream that is accepted (the months that display well) visible. Then I could compare.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39695334
You might consider using PHP error_log() to record the data.  I believe you can also set error_reporting() and log_errors separately, so you can see the errors in the logs.

I'll add this to the Drupal Zone, too.
0
 

Author Comment

by:TheoRichel
ID: 39695375
Thanks
PHPInfo tells me that there is no error log specified and my host does not allow me access to the PHP.ini. (I guess I chose the wrong host).
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39703089
Tell your host to set up error_log.  It's not optional -- you cannot work without it.  It would be like Schroedinger trying to be a veterinarian.  You must be able to get quick and accurate visualization of error messages.

Who is the host?  I'd like to add them to my list of "do not disturb" entities.
0
 

Author Comment

by:TheoRichel
ID: 39716128
The host is mijndomein.nl . I contacted them about this and will let you know.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39716600
While you're waiting to hear back from them, you might want to post a question here and ask about the high-quality hosting services that would be available in your country.  Or contact this fellow and ask what hosts he would recommend.
http://www.dragonbe.com/
0
 

Author Comment

by:TheoRichel
ID: 39735989
I will and will migrate to another host, but this is going to take some time and I do not know whether this problem will popup there as well, so I'll close this question.Many thanks sofar.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39736014
Thanks for the points and best of luck with it, ~Ray
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question