所以我在尝试向我的数据库添加新值时遇到错误,到目前为止代码:
<?php
include 'config.php';
$con=mysqli_connect("localhost","labas_main","1Ym9ZnPP","labas_main");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$field1 = isset( $_POST['darbuotojas']) ? $_POST['darbuotojas'] : "";
$field2 = isset( $_POST['objektas']) ? $_POST['objektas'] : "";
$field3 = isset( $_POST['dirbo']) ? $_POST['dirbo'] : "";
//atstatom busena i INT kintamaji
if ($field3 == "ne") {
$field3=0;
}
elseif ($field3 == "taip") {
$field3=1;
}
else $field3=2;
$field4 = isset( $_POST['data']) ? $_POST['data'] : "";
mysqli_query($con,"INSERT INTO 'suvestine' ('atsiskaitymas', 'darbuotojo_ID', 'data', 'objekto_ID')
VALUES ('".$field3."', '".$field1."', '".$field4."', '".$field2."')";
?>
错误:
解析错误:语法错误,意外&#39 ;;&#39;在/home/labas/domains/labasgas.lt/public_html/crm/suvestine_add.php第30行
答案 0 :(得分:0)
您的查询错误:quotes
且遗失)
mysqli_query($con,"INSERT INTO suvestine (atsiskaitymas, darbuotojo_ID, data, objekto_ID) VALUES ('".$field3."', '".$field1."', '".$field4."', '".$field2."')");