我有一个像下面这样的小 php 页面,我想从此插入返回“auto-incremented_id”。
唯一的要求是我可以从 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
));
?>