小编Emm*_*mmy的帖子

在代号为1时使用webservices时如何解析null

我在php中调用数据库中的数据,并使用Webservices将数据传递给代号.如果我将我的URL指向JSON文件,我能够获取我的记录,但当我将其更改为php并使用JSON对页面进行编码时,我将变为null.

在Codename中使用Webservices时如何解决null结果?

这是我用代码名称调用的PHP代码

<?php 
/* require the user as the parameter */
//http://localhost:8080/sample1/webservice1.php?user=1
if(isset($_GET['user']) && intval($_GET['user'])) {
    /*soak in the passed variable or set our own*/
    //$number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; //10 is the default
    $format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; //xml is  the default
    //$user_id = intval($_GET['user']); //no default

    /* connect to the db */
    $link = mysql_connect('localhost','root','') or die('Cannot connect to the DB');
    mysql_select_db('test',$link) or die('Cannot select the DB');

    /* grab the posts …
Run Code Online (Sandbox Code Playgroud)

php codenameone

5
推荐指数
1
解决办法
361
查看次数

标签 统计

codenameone ×1

php ×1