由于某种原因,我的查询无法正常工作,我将发布$ _POST的代码和输出。MySQL查询无法正常工作 - 无错误
我还将添加数据库结构的屏幕截图。
$ _ POST:
代码:数据库
ini_set('display_errors',1);
error_reporting(E_ALL);
echo "<pre>";
var_dump($_POST);
echo "</pre>";
$mysqli = new mysqli("localhost", "lunar_casino", "******", "lunar_casino");
if(isset($_POST['submit'])){
$error = array();
if(empty($error)){
$bonus = $_POST['bonus'];
$deposit = $_POST['deposit'];
$offers = $_POST['offers'];
$link = $_POST['link'];
$name = $_POST['logo'];
$q = $mysqli->query("INSERT INTO `lunar_casino`.`casino` VALUES(NULL, '$bonus', '$deposit', '$offers', '$link', '$logo', '$name', NULL)");
if(!$q){
echo "<font color='red'><b>There has been an error with our database! Please contact the website administrator!</b></font><br /><br />";
} else {
echo "<font color='green'><b>You have successfully added the casino!</b></font><br /><br />";
}
} else {
echo "<font color='red'><b>There were ".count($error)." errors in your form:</b></font><br />";
foreach($error as $err){
echo "<b>".$err."</b><br />";
}
echo "<br />";
}
}
结构:
如果您需要更多的信息,只是让我知道!
顺便说一句,我知道错误是在查询中的方式是因为我检查如果(!$ q),并使得它显示错误消息,如果查询不能完成,它会显示错误消息在页面上。
任何想法为什么它不工作?此外,我从查询中排除日期,因为我不知道如何将当前日期:时间添加到查询中。
如果任何人都可以帮助解决这些问题,请让我知道! :)
你的代码是SQL注入攻击敞开的。 – arkascha
但我们不被允许知道错误信息是什么意思? – Strawberry
将查询保存为字符串并将其打印出来。 –