我正在做项目,它需要android-PHP-MySQL连接。 我编写了PHP代码,但它不起作用。错误代码显示“未定义索引:userId ...' 我不知道如何解决它。我用谷歌搜索得到一些解决方案,但我找不到正确的答案。其他PHP代码与另一个Android项目正在工作。为什么..?
以下是我的PHP代码。
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require "init.php";
$userId = $_POST["userId"];
$username = $_POST["username"];
$userphone = $_POST["userphone"];
$usermail = $_POST["usermail"];
$userpw = $_POST["userpw"];
$sql = "INSERT INTO register_info VALUES ('$userId', '$username', '$userphone', '$usermail', '$userpw' );";
if(mysqli_query($con, $sql))
{
var_dump($userId,$username,$userphone,$usermail, $userpw );
}
?>
这是错误代码。
Notice: Undefined index: userId in /var/www/html/website/web/webapp/insertUser.php on line 9
Notice: Undefined index: username in /var/www/html/website/web/webapp/insertUser.php on line 10
Notice: Undefined index: userphone in /var/www/html/website/web/webapp/insertUser.php on line 11
Notice: Undefined index: usermail in /var/www/html/website/web/webapp/insertUser.php on line 12
Notice: Undefined index: userpw in /var/www/html/website/web/webapp/insertUser.php on line 13
string(0) "" string(0) "" string(0) "" string(0) "" string(0) ""
答案 0 :(得分:-1)
查询mysql有解决方案。
试
$sql = "INSERT INTO register_info (userId, username, userphone, usermail, userpw) VALUES ('$userId', '$username', '$userphone', '$usermail', '$userpw' );";
或参见