我有一個像下面這樣的小php頁面,我想從此插入中返回「auto-incremented_id」。Mysql返回值
唯一的要求是我可以從android應用程序讀取數字。我敢肯定,我可以查看它,但有代碼SQL
代碼我可以檢查成功,將返回它?
這裏的PHP:
<?php
//Make connection
$con = mysqli_connect('xxxxx', 'xxxxxxx', 'xxxxx');
//check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//change db to andriodnfp db
mysqli_select_db($con, 'andriodnfp');
$table = 'USER';
$fbid = htmlspecialchars($_GET["fbid"]);
$social = htmlspecialchars($_GET["social"]);
$name = htmlspecialchars($_GET["name"]);
$name = !empty($name) ? "'$name'" : "NULL";
$fname = htmlspecialchars($_GET["fname"]);
$fname = !empty($fname) ? "'$fname'" : "NULL";
$username = htmlspecialchars($_GET["username"]);
$username = !empty($username) ? "'$username'" : "NULL";
$email = htmlspecialchars($_GET["email"]);
$email = !empty($email) ? "'$email'" : "NULL";
$picture = htmlspecialchars($_GET["picture"]);
$picture = !empty($picture) ? "'$picture'" : "NULL";
$other = htmlspecialchars($_GET["other"]);
$other = !empty($other) ? "'$other'" : "NULL";
if (!$fbid == '') {
if (!mysqli_query($con, 'INSERT INTO ' . $table . ' (facebookID, social_outlet, Name, first_name, username, email, picture, significant_other) VALUES ("' . $fbid . '","' . $social . '","' . $name . '","' . $fname . '","' . $username . '","' . $email . '","' . $picture . '","' . $other . '")')) {
printf("Errormessage: %s\n", mysqli_error($con));
};
}
mysqli_close($con);
//$posts = array($json);
$posts = array(
1
);
header('Content-type: application/json');
echo json_encode(array(
'posts' => $posts
));
?>
反正它不屬於'android'。 –
這與如何在Anroid應用程序中讀取json有關。 –
如果所討論的代碼位於PHP和MySQL之間,那麼即使使用其他語言,它們也不相關。 –