我有以下代码应该从前一页收集填充值并将它们插入到MySQLi数据库中。这不起作用,我只收到一个空白页面,没有任何消息。我无法弄清楚我做错了什么。代码不会插入到数据库
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
if(mysqli_connect_errno())
{
echo mysqli_connect_error();
}
$company_name = $_POST['company_name'];
$description = $_POST['description'];
$welcome_text = $_POST['welcome_text'];
$thanks_message = $_POST['thanks_message'];
$image = addslashes (file_get_contents($_FILES['image']['tmp_name']));
$logo = getimagesize($_FILES['image']['tmp_name']);
$image_type = $logo['mime'];
$q = "INSERT INTO project VALUES('','$company_name','$description','$image','$image_type','$welcome_text','$thanks_message')";
$r = mysqli_query($mysqli,$q);
if($r)
{
echo "<h1>Projektet är skapat!</h1><br>
Tryck på knappen nedan för att ta dig till Dashboard.<br><br>
<a href='dashboardadmin.php'><button id='projectbutton'>Dashboard</button></a>";
}
else
{
echo mysqli_errno($mysqli) . ": " . mysqli_error($mysqli) . "\n";
}
?>
错误????????? PLZ? – devpro
你至少需要“清理”你的输入;参数化查询会更好。 – Uueerdo
[您的脚本存在SQL注入攻击的风险。](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)了解[prepared](http: //en.wikipedia.org/wiki/Prepared_statement)[MySQLi]的声明(http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)。 –