Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSON+;PHP+;Java-Android登录mysql_Android_Mysql_Json - Fatal编程技术网

JSON+;PHP+;Java-Android登录mysql

JSON+;PHP+;Java-Android登录mysql,android,mysql,json,Android,Mysql,Json,我有个问题。。。 当用户注册时,我试图将设备的udid存储到我的数据库中。。。 我在logcat中发现了这个错误: 10-18 17:17:08.141: E/JSON(1712): <br /> 10-18 17:17:08.141: E/JSON(1712): <b>Warning</b>: Missing argument 4 for DB_Functions::storeUser(), called in /home/matbest1/public_

我有个问题。。。 当用户注册时,我试图将设备的udid存储到我的数据库中。。。 我在logcat中发现了这个错误:

10-18 17:17:08.141: E/JSON(1712): <br />
10-18 17:17:08.141: E/JSON(1712): <b>Warning</b>:  Missing argument 4 for DB_Functions::storeUser(), called in /home/matbest1/public_html/android_login_api/index.php on line 64 and defined in <b>/home/matbest1/public_html/android_login_api/include/DB_Functions.php</b> on line <b>25</b><br />
10-18 17:17:08.141: E/JSON(1712): {"tag":"register","success":0,"error":1,"error_msg":"Error occured in Registartion"}
10-18 17:17:08.151: E/JSON Parser(1712): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
10-18 17:17:08.381: D/dalvikvm(1712): GC_CONCURRENT freed 296K, 5% free 9394K/9799K, paused 2ms+4ms
php代码:

 public function storeUser($name, $email, $password, $uid) {
    $uuid = $uid;
    $hash = $this->hashSSHA($password);
    $encrypted_password = $hash["encrypted"]; // encrypted password
    $salt = $hash["salt"]; // salt
    $result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email', '$encrypted_password', '$salt', NOW())");
    // check for successful store
    if ($result) {
        // get user details 
        $uid = mysql_insert_id(); // last inserted id
        $result = mysql_query("SELECT * FROM users WHERE uid = $uid");
        // return user details
        return mysql_fetch_array($result);
    } else {
        return false;
    }
}
&


有人能帮我吗?我是新来的。。。非常感谢。

服务器响应包含一个以HTML显示的PHP错误

因此,android应用程序无法解析任何JSON是正常的

首先,您需要确保android应用程序发送所有需要的信息(PHP等待的4个参数),因为PHP错误清楚地告诉您它缺少参数#4:$uid

试试看
print\r($\u请求)

在php文件的开头,查看php是否接收到所有参数。。如果不是:问题出在android应用程序中(uid是字符串?整数?需要转换吗?

值,因此在解析udid时出现了一些错误?请阅读错误消息。我看不出有什么不对吗,我是新来的,你能帮我吗?我不知道我能帮你什么,除了告诉你你的JSON格式不正确。你需要弄清楚它为什么格式不正确。堆栈溢出不是调试器。
UserFunctions userFunction = new UserFunctions();
            JSONObject json = userFunction.registerUser(name, email, password, uid);
 public function storeUser($name, $email, $password, $uid) {
    $uuid = $uid;
    $hash = $this->hashSSHA($password);
    $encrypted_password = $hash["encrypted"]; // encrypted password
    $salt = $hash["salt"]; // salt
    $result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email', '$encrypted_password', '$salt', NOW())");
    // check for successful store
    if ($result) {
        // get user details 
        $uid = mysql_insert_id(); // last inserted id
        $result = mysql_query("SELECT * FROM users WHERE uid = $uid");
        // return user details
        return mysql_fetch_array($result);
    } else {
        return false;
    }
}
  if ($tag == 'register') {
        // Request type is Register new user
        $name = $_POST['name'];
        $email = $_POST['email'];
        $password = $_POST['password'];
        $uid = $_POST['uid'];

        // check if user is already existed
        if ($db->isUserExisted($email)) {
            // user is already existed - error response
            $response["error"] = 2;
            $response["error_msg"] = "User already existed";
            echo json_encode($response);
        } else {
            // store user
            $user = $db->storeUser($name, $email, $password);
            if ($user) {
                // user stored successfully
                $response["success"] = 1;
                $response["uid"] = $user["unique_id"];
                $response["user"]["name"] = $user["name"];
                $response["user"]["email"] = $user["email"];
                $response["user"]["created_at"] = $user["created_at"];
                $response["user"]["updated_at"] = $user["updated_at"];
                echo json_encode($response);
            } else {
                // user failed to store
                $response["error"] = 1;
                $response["error_msg"] = "Error occured in Registartion";
                echo json_encode($response);
            }
        }
    } else {
        echo "Invalid Request";
    }
} else {
    echo "Access Denied";
}