admin管理员组文章数量:1356591
I have a php file in which i believe this line
sendResponse(200, json_encode($result));
is failing because values from my select (from eariler in the program) are not getting passed back to my app ( i checked connection and user and it is all correct ).
I am using php version 5.3.10 and it says nothing about JSON in the config i pared my phpinfo with an online server where this works and in the phpinfo() i see JSON support=enabled, JSON version=1.2.1. Which had me thinking maybe this will work if JSOn is installed. However I was told that JSON automatically es with php version 5+. I would like to know if that is true or if this may be failing because JSON is not enabled on my localhost server. thank you
JSONParser parser = new JSONParser("/", this);
parser.setPostData(requestParams.toString().getBytes());
parser.setRequestType(true);
parser.start();
}
public void onResponse(String data, int code) {
// TODO Auto-generated method stub
final Vector firearmInfo = jasonParser.parseFirearmResponse(data);
if(firearmInfo.size() > 0 ){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// TODO Auto-generated method stub
removeLoader();
UiApplication.getUiApplication().pushScreen(new FirearmSearchResultScreen(firearmInfo));
}
});
}else{
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// TODO Auto-generated method stub
removeLoader();
Dialog.alert("No Results found.");
}
});
}
}
I have a php file in which i believe this line
sendResponse(200, json_encode($result));
is failing because values from my select (from eariler in the program) are not getting passed back to my app ( i checked connection and user and it is all correct ).
I am using php version 5.3.10 and it says nothing about JSON in the config i pared my phpinfo with an online server where this works and in the phpinfo() i see JSON support=enabled, JSON version=1.2.1. Which had me thinking maybe this will work if JSOn is installed. However I was told that JSON automatically es with php version 5+. I would like to know if that is true or if this may be failing because JSON is not enabled on my localhost server. thank you
JSONParser parser = new JSONParser("http://www.myhost.co.nf/firearm/", this);
parser.setPostData(requestParams.toString().getBytes());
parser.setRequestType(true);
parser.start();
}
public void onResponse(String data, int code) {
// TODO Auto-generated method stub
final Vector firearmInfo = jasonParser.parseFirearmResponse(data);
if(firearmInfo.size() > 0 ){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// TODO Auto-generated method stub
removeLoader();
UiApplication.getUiApplication().pushScreen(new FirearmSearchResultScreen(firearmInfo));
}
});
}else{
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// TODO Auto-generated method stub
removeLoader();
Dialog.alert("No Results found.");
}
});
}
}
Share
Improve this question
edited Mar 6, 2013 at 4:41
Michael Donohue
11.9k5 gold badges33 silver badges44 bronze badges
asked Mar 5, 2013 at 20:53
kemnetkemnet
731 gold badge3 silver badges11 bronze badges
13
- What exactly goes wrong at which point, can you clarify what happens? Are you getting any errors? – Pekka Commented Mar 5, 2013 at 20:54
-
3
just test a single
<?php echo json_encode(array("a"=>"b")); ?>
and you will see if the encode function is working properly. – Balázs Édes Commented Mar 5, 2013 at 20:57 - @Pekka웃 simply...I have an app, which goes to webhost...runs a select..and returns me back values...this works flawlessly on ever server i try except on a localhost server. All credentials are correct, the user is properly configure and the where clause is satisfied...but nothing...gets posted to the results array and an empty array of results is passed back to my app and i believe i am write because my program gives me an error of "no results found" (refer first message for that code) – kemnet Commented Mar 5, 2013 at 21:05
-
If you'd try to run
json_encode()
on a server where it isn't installed, you'd get a fatal error. Your problem is likely to be elsewhere. – Pekka Commented Mar 5, 2013 at 21:06 -
1
<?php echo (function_exists('json_encode'))?'installed':'not installed'; ?>
– Sammitch Commented Mar 5, 2013 at 21:07
2 Answers
Reset to default 7As of PHP 5.2.0, the JSON extension is bundled and piled into PHP by default.
As quoted from: http://www.php/manual/en/json.installation.php
So there is no need to check for JSON patibility on modern PHP versions.
Although your problem is different than the question asked and you identified it in one of your ments, you did not change the question.
This answer addresses your PROBLEM. I had the same happen to me yesterday:
Query collecting JSON data from MySQL to PHP worked on local server, but when ported to production server Online array returned empty. It turned out that the MySQL version of the production server was 5.6xx and the local server 5.7xx. That difference was the answer. MySQL started supporting JSON data in 5.7 according to this SitePoint article.
ANSWER:
- update your MySQL to 5.7+ (problem solved)
OR
- Retrieve JSON data as text (MySQL 5.6) and use PHP json_decode() to either an object or an array
本文标签: phpTrouble Figuring out if JSON is installed or notStack Overflow
版权声明:本文标题:php - Trouble Figuring out if JSON is installed or not - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744039754a2580444.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论