这是我的代码。我没有收到错误声明,但数据没有插入到表中。我尝试在 PHPMyAdmin 中运行查询,它运行良好。这也不是因为用户权限。
if ($mysql->connect_errno) {
echo("Connect failed: ". $mysql->connect_error);
die();
}
echo "I am confused by this thing<br>";
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
echo "Trying to figure out the errors!!!!<br>";
$fileName = $mysql->real_escape_string($_FILES['userfile']['name']);
$tmpName = $mysql->real_escape_string($_FILES['userfile']['tmp_name']);
$fileSize = intval($_FILES['userfile']['size']);
$fileType = $mysql->real_escape_string($_FILES['userfile']['type']);
echo $fileName."<br>";
echo $tmpName."<br>";
echo $fileSize."<br>";
echo $fileType."<br>";
//reads the file information
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = $mysql->real_escape_string(addslashes($content));
fclose($fp);
//this just adds slashes
这增加了斜线
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
//This inserts into the databse
$query = "INSERT INTO upload VALUES ('', '$fileName', '$fileType', $fileSize, '$content')";
这是代码混乱的那一行......它只是挂起并且从不打印出死亡消息
$updateDB = $mysqli->query($query) or die($mysqli->error);
它永远不会打印出这一行。
echo "<br>File $fileName uploaded<br>";
}