我正在尝试编写一个 MySQL 语句来向表中插入信息:
$insert = "INSERT INTO `vle`.`files`
(`id`, `time`, `fileLocation`, `title`, `user`)
VALUES (
NULL,
UNIX_TIMESTAMP(),
'".mysql_real_escape_string($putFile)."',
'".mysql_real_escape_string($_POST['title'])."',
'".$user."'
)";
一切都正确插入,除了回显$user
但没有插入的变量,对于$putFile
. 这个 MySQL 语句中有什么我做错了吗?
谢谢
完整代码在这里
<?php require_once('Connections/localhost.php');
include('pageCheck.php');
include('adminCheck.php');
function saveFile(){
global $_FILES, $_POST;
$insert = "INSERT INTO `vle`.`files`
(`id`, `time`, `fileLocation`, `title`, `user`)
VALUES (NULL, UNIX_TIMESTAMP(), '".mysql_real_escape_string($putFile)."', '".mysql_real_escape_string($_POST['title'])."', '".$user."')";
mysql_query($insert);
var_dump($insert);
}
$putFile = "files/".basename($_FILES['uploadedFile']['name']);
if(move_uploaded_file($_FILES['uploadedFile']['tmp_name'], $putFile)){
saveFile();
echo"File has been uploaded, Redirecting to file list now...";
//echo"<meta http-equiv='refresh' content='3;url=dashboard.php'>";
}else{
echo"Unable to upload file, Returning to dashboard...";
//echo"<meta http-equiv='refresh' content='3;url=dashboard.php'>";
}
?>
$user 我们在 pageCheck.php 中定义