这个问题在这里已经有答案了:
如何显示mysqli查询的错误[重复](2个答案)
引用-这个错误在php中是什么意思(36个答案)
两年前关门了。
我试图添加新行到数据库,但是,它没有添加,我没有收到一个错误。代码在本地工作,但在web上不工作。
这是代码;
$RoomNo = mysqli_real_escape_string($conn,$_POST["roomno"]);
$Lastname = mysqli_real_escape_string($conn,$_POST["lastname"]);
$Name = mysqli_real_escape_string($conn,$_POST["name"]);
$Arrival = mysqli_real_escape_string($conn,$_POST["arrival"]);
$Departure = mysqli_real_escape_string($conn,$_POST["departure"]);
$EventType = mysqli_real_escape_string($conn,$_POST["eventtype"]);
$AssignedUser = mysqli_real_escape_string($conn,$_POST["assigned_user"]);
$Comment = mysqli_real_escape_string($conn,$_POST["comment"]);
$Action = mysqli_real_escape_string($conn,$_POST["action"]);
$ChooseAssignedUser = explode("|", $AssignedUser);
$eventregister_sql = "INSERT INTO tbl_event (room,lastname,name,arrival,departure,event_type,assigned_user,department,comment,action,user,update_user,call_time,update_time,status,hotel_id) VALUES ('".$RoomNo."','".$Lastname."','".$Name."','".$Arrival."','".$Departure."','".$EventType."','".$ChooseAssignedUser[0]."','".$ChooseAssignedUser[1]."','".$Comment."','".$Action."',".$_SESSION['user_id'].",".$_SESSION['user_id'].",'$gmtdbro','$gmtdbro','N',".$_SESSION['hotel_id'].")";
$eventregister_result = $conn->query($eventregister_sql);
echo "<center>Event registered successfuly. <a href=\"index.php\">Go back to main page</a>.</center>
1条答案
按热度按时间lnlaulya1#
首先,我建议您使用pdo在数据库中插入数据。。。优点是
无需使用mysqli\u real\u escape\u字符串
可读代码
等
http://php.net/manual/en/pdostatement.bindvalue.php
然后在您的示例中,尝试打印sql字符串并在phpmyadmin中准确地使用该字符串来找出发生了什么
尝试使用var\u dump返回值来查看发生了什么
或者