我已经更新了这个以包括评论者的方向,这是设置的方式,如果我将mysqli_query注释置于条件之外,它写入,当没有发生任何事情时(即使有一个空表)。我在select语句中执行条件的方式一定有问题,但是当我直接将它输入到phyadmin中时,它是正确的语法。
$sql_write_new = "INSERT INTO `bc_bba_squarecoordinates`.`load_records` (`id`,`sqr_num`,`amphibian`,`lizard`,`snake`,`turtle`) VALUES (NULL,'$sqrNum','$amphibianBool','$lizardBool','$snakeBool', '$turtleBool');";
$sql_read_loadSpecies = "SELECT * FROM `bc_bba_squarecoordinates`.`load_records` WHERE `sqr_num` = '$sqrNum');";
$query = mysqli_query($con, $sql_read_loadSpecies) or die();
if(mysqli_num_rows($query) > 0){
// row exists
//check_taxa(); // function that sets boolean values based on user input from submit_records
//mysqli_query($con, $sql_write_update) or die();
}
else{
// if zero then no record exists, write a new one
//check_taxa();
mysqli_query($con, $sql_write_new) or die();
mysqli_close($con);
}