php mysql如何修复此错误:未定义变量:C中的id:\
如何修复错误: 未定义变量:38中c:\wamp\www\android\u connect\status.php中的id 我做错了什么 status.phpphp mysql如何修复此错误:未定义变量:C中的id:\,php,mysql,session,error-handling,Php,Mysql,Session,Error Handling,如何修复错误: 未定义变量:38中c:\wamp\www\android\u connect\status.php中的id 我做错了什么 status.php 像这样更改插入查询 $sql = mysql_query("INSERT INTO status (status_text, uid)VALUES('".$status."', '".$id."')")or die(mysql_error()); 您得到的错误意味着$id未设置。在代码中没有检查$id变量 将else-if(isset(
像这样更改插入查询
$sql = mysql_query("INSERT INTO status (status_text, uid)VALUES('".$status."', '".$id."')")or die(mysql_error());
您得到的错误意味着$id未设置。在代码中没有检查$id变量
将else-if(isset($\u-POST['status']){
更改为else-if(isset($\u-POST['status'])和&isset($id)){
然后添加一个else语句,类似这样:
else {
// failed to insert row because of missing $id
$response["success"] = 0;
$response["message"] = "Error in saving the status, session variable $id missing";
// echoing JSON response
die (json_encode($response));
}
嗯,$id
仅在(isset($\u SESSION['id'])
的情况下定义。否则它不存在。的可能重复项
else {
// failed to insert row because of missing $id
$response["success"] = 0;
$response["message"] = "Error in saving the status, session variable $id missing";
// echoing JSON response
die (json_encode($response));
}