gpt4 book ai didi

php - PHP检查多个文本框并插入数据错误

转载 作者:搜寻专家 更新时间:2023-10-31 21:27:20 24 4
gpt4 key购买 nike

这个问题已经有了答案:
PHP parse/syntax errors; and how to solve them?
17个答案

<?php
$carCompany = $mysqli->real_escape_string($_POST['carCompanyName']);
$carName = $mysqli->real_escape_string($_POST['carName']);
$carModel = $mysqli->real_escape_string($_POST['carModel']);
$carColor = $mysqli->real_escape_string($_POST['carColor']);
$carFuelType = $mysqli->real_escape_string($_POST['carFuelType']);
$carPlate = $mysqli->real_escape_string($_POST['carPlate']);
$carOwnerName = $mysqli->real_escape_string($_POST['carOwnerName']);
$carDescription = $mysqli->real_escape_string($_POST['carDescription']);

if ($_POST) {
if (!isset($_POST['carCompanyName'])) || strlen($_POST['carCompanyName'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carName'])) || strlen($_POST['carName'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carModel'])) || strlen($_POST['carModel'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carColor'])) || strlen($_POST['carColor'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carPlate'])) || strlen($_POST['carPlate'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carOwnerName'])) || strlen($_POST['carOwnerName'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}
if (!isset($_POST['carOwnerName'])) || strlen($_POST['carOwnerName'])<1 {

die('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Danger!</strong> Indicates a dangerous or potentially negative action.</div>');
}

if(mysqli_query($mysqli, "INSERT INTO cars(car_plate_no, car_company_name, car_name, car_model, car_color, car_fuel_type, car_owner_name, car_description) VALUES ('$carPlate','$carCompany','$carName','$carModel','$carColor','$carFuelType','$carOwnerName','$carDescription')" )){
printf("%d Row Inserted.\n", mysqli_affected_rows($mysqli));
}

}

?>

错误说明:
分析错误:语法错误,在第33行的C:\xampp\htdocs\meccaniko\work\profile\add-car.php中出现意外的“”(t_boolean_or)
这段代码怎么了,上面写着这是出乎意料的
帮助我选中空文本框并运行上面的插入查询

最佳答案

你把)放错位置了。

if (!isset($_POST['carCompanyName']) || strlen($_POST['carCompanyName'])<1) {

}

关于php - PHP检查多个文本框并插入数据错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34250781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com