Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JSON Encoding problem breaks calendar

Posted on 2013-12-03
13
Medium Priority
?
559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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 your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

722 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