You are here: problem with php, json, browser, charset « PHP Language « IT news, forums, messages
problem with php, json, browser, charset

Posted by Pugi! on 01/05/08 17:04

Hi,

I am having a problem that is occuring when using php, json, utf-8
charset and IE7.
It sounds like a browser (thus client side) problem but since it is
occuring on a php driven website, I think the best help I can get is
here.
Given: webpage (valid XHTML, utf-8 charset) with form (I use the YUI
dialog), using javascript I collect all the user input on the form,
store it in an object, json encode it, send it to the server (AJAX
GET, no form submit), json decode it, validate and sanitize it, store
it in database when ok, otherwise create error message and send
response back to the client.
The problem occures when the user inputs coordinates like 53°16'35''.
which is allowed. It works fine with FF, Safari and Opera, but not
with IE7 (dont' know for IE6). Before the request is send to the
server I visualize the json encoded information and the url with
querystring in an alert and there is no difference here between IE7
and other browsers, but once it arrives on the server there is a
difference:
The first log line is the url + querystring, the second line is the
result of $_GET['data'].
When I use json_decode(stripslashes($data), true) the result is an
associative array for FF, Safari and Opera, but empty for IE7. Where
is the problem ? The charset, the urlencoding, ... ?

FF, Safari, Opera log:
05/01/2008 17:37:45 - 192.168.1.2 - url = /webpage.php?
action=modform&data={%22FormID%22:%2221%22,%22FieldsetID
%22:%2287%22,%22XAttrID%22:%2218%22,%22Label%22:%22Max.%20longitude
%22,%22Units%22:%22%22,%22ToolTip%22:%22Maximum%20longitude
%20(-180%20to%20180).%20Valid%20formats
%20:%2053.5,%2053%C2%B016.2,%2053%C2%B016'20.5%20and%2053%C2%B016'22''.
%22,%22MinValue%22:%22-180%22,%22MaxValue%22:%22a%22,%22ListID
%22:%22%22,%22InputTypeID%22:%228%22,%22Multiple%22:false,%22Required
%22:false}

05/01/2008 17:37:45 - 192.168.1.2 - get data = {\"FormID\":\"21\",
\"FieldsetID\":\"87\",\"XAttrID\":\"18\",\"Label\":\"Max. longitude\",
\"Units\":\"\",\"ToolTip\":\"Maximum longitude (-180 to 180). Valid
formats : 53.5, 53°16.2, 53°16\'20.5 and 53°16\'22\'\'.\",\"MinValue\":
\"-180\",\"MaxValue\":\"a\",\"ListID\":\"\",\"InputTypeID\":\"8\",
\"Multiple\":false,\"Required\":false}


IE7 log:
05/01/2008 17:38:55 - 192.168.1.2 - url = /webpage.php?
action=modform&data={"FormID":"21","FieldsetID":"87","XAttrID":"18","Label":"Max.
%20longitude","Units":"","ToolTip":"Maximum%20longitude%20(-180%20to
%20180).%20Valid%20formats%20:%2053.5,%2053°16.2,%2053°16'20.5%20and
%2053°16'22''.","MinValue":"-180","MaxValue":"a","ListID":"","InputTypeID":"8","Multiple":false,"Required":false}

05/01/2008 17:38:55 - 192.168.1.2 - get data = {\"FormID\":\"21\",
\"FieldsetID\":\"87\",\"XAttrID\":\"18\",\"Label\":\"Max. longitude\",
\"Units\":\"\",\"ToolTip\":\"Maximum longitude (-180 to 180). Valid
formats : 53.5, 53°16.2, 53°16\'20.5 and 53°16\'22\'\'.\",\"MinValue\":
\"-180\",\"MaxValue\":\"a\",\"ListID\":\"\",\"InputTypeID\":\"8\",
\"Multiple\":false,\"Required\":false}


thanx in advance,

Pugi!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация