gpt4 book ai didi

mysql - 检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行 ' masalah = ' dsd' AND gambar = 'kerusi.JPG' ' 附近使用的正确语法

转载 作者:行者123 更新时间:2023-11-29 07:36:21 27 4
gpt4 key购买 nike

我想将记录添加到包含图片的表中。当我尝试添加时,它向我显示此错误

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的 ' masalah = 'dsd' AND gambar = 'kerusi.JPG'' 附近使用的正确语法

所以,这是代码

<?php

session_start();
include("Connections/connection.php");

$date = $_POST['date'];
$masalah = $_POST ['masalah'];
$gambar = $_POST ['gambar'];
$student_id = $_POST['student_id'];
$status = 'pending';

/*session yg di call tok lecturer tu*/

$student_id = "SELECT * FROM student WHERE student_id ='".$_SESSION['student_id']."'" ;
$result=mysql_query($student_id);
$getstudentid = mysql_fetch_assoc($result);
$student_id = $getstudentid['student_id'];

/*take 3 data from rc */

$sql = "SELECT * FROM aduan WHERE date = '$date', masalah = '$masalah' AND gambar = '$gambar' ";

$rr = mysql_query($sql) or die(mysql_error());
$tt = mysql_num_rows($rr);

if($tt > 0) {

header("Location: borang_aduan2.php?error=2");

} else { /*to check tarikh*/

$tarikh_user = strtotime($date);
$tarikh_harini = strtotime(date('Y-m-d'));

if($tarikh_user < $tarikh_harini) {
//error
header("Location: borang_aduan2.php?error=1");
} else {

//$No = $num_rows+1;
/*$sql_const = mysql_query ("Select MAX(user_name)as id from lecturer")or die (mysql_error());
$rows = mysql_fetch_array ($sql_const);
$id = $rows ['id'];*/

/*insert data*/

mysql_query("INSERT INTO aduan (date, masalah, gambar, student_id )
VALUES('$date','$masalah', '$gambar','$student_id')")

or die('Error: ' .mysql_error($conn));
echo "<script type='text/javascript'>
alert('Thanks make a report!')
location.href='borang_aduan2.php'
</script>";


}

//Freeing all memory associated with it
mysql_free_result($result);
//Closes specified connection
mysql_close($conn);
}
?>

最佳答案

不要在两个字段选择条件之间使用“,”。所以代替:

SELECT * FROM aduan WHERE date = '$date', 
^^

使用

SELECT * FROM aduan WHERE date = '$date' AND 

关于mysql - 检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行 ' masalah = ' dsd' AND gambar = 'kerusi.JPG' ' 附近使用的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30691879/

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