我使用以下命令插入一行:
create.php
<?php
require_once 'db_connect.php';
if($_POST) {
$validator = array('success' => false, 'messages' => array());
$a = $_POST['id'];
$b = $_POST['number'];
$sql = "INSERT INTO class (id, number)
SELECT '$a', '$b'
WHERE EXISTS (SELECT * FROM members WHERE idmember = $a AND active = 1)";
$query = $connect->query($sql);
if($query === TRUE) {
$validator['success'] = true;
$validator['messages'] = "Message : OK!";
} else {
$validator['success'] = false;
$validator['messages'] = "Message : ERROR!";
}
$connect->close();
echo json_encode($validator);
}
当我向该表添加一个字段时,该活动是= 1,我没有问题,并添加了该行。 当我向该表添加一个字段时,该active是= 0,该行不会被添加到数据库mysql中,但是&#34;消息:OK!&#34;显示。为什么呢?