插入目录文件夹中的图像不在数据库中?请看代码,图像可以在文件夹中查看,但不能在数据库中查看pc.gif而不是命令,否则在命令上执行文件名但是执行了else?第一个命令是正确执行第二个命令的原因。
if($action=="insertproject"){
if ($_FILES['logo']['name'] != "") {
$imageInfo = getimagesize($_FILES['logo']['tmp_name']); // get image size
$width = $imageInfo[0]; // image width
$height = $imageInfo[1]; // image height
if($height > 2000 || $width > 2000){
echo "<script> alert('Image is to big! Try to resize the picture!') </script>";
exit;
} // check size
$newimg1 = date("YmdHis").".jpg"; // set name for new image
$newimg2 = date("YmdHis").".pdf"; // set name for pdf if is necesary
if(stristr($_SERVER['OS'],"win")){
$path = "prodimg/";
} // determin path of image folder
elseif(stristr($_SERVER['OS'],"linux")){
$path = str_replace("admin.php","",$_SERVER['SCRIPT_FILENAME']) . "prodimg/";
}
else {
$path = "prodimg/";
}
move_uploaded_file ( $_FILES['logo']['tmp_name'], $path . $newimg1 );
} // copy image in image folder
else{
$newimg1="pc.gif";
} // if is not posible than set image name as pc.gif
$serviceid = $_POST['serviceid'];
$projectcode = $_POST['projectcode'];
$projecttitle = $_POST['projecttitle'];
$update = $_POST['update'];
$projectstatus = $_POST['projectstatus'];
$progress = "on progress";
$sector = $_POST['sector'];
$dateofrtecreview = $_POST['dateofrtecreview'];
$dateapprovedatrpmolevel = $_POST['dateapprovedatrpmolevel'];
$dateendorsedtonpmo = $_POST['dateendorsedtonpmo'];
$dateapprovednpmo = $_POST['dateapprovednpmo'];
$datereceivedbyrpmo = $_POST['datereceivedbyrpmo'];
$expectedoutput = $_POST['expectedoutput'];
$yearassistancereceived = $_POST['yearassistancereceived'];
$setupinvestment = $_POST['setupinvestment'];
$beneficiaryinvestment = $_POST['beneficiaryinvestment'];
$projectdescription = $_POST['projectdescription'];
$res = mysql_query("insert into appointment_detail(`serviceid`,`picture`,`projectdescription`,`dateofrtecreview`,`dateapprovedatrpmol evel`,`dateendorsedtonpmo`,`dateapprovednpmo`,`datereceivedbyrpmo`,`expectedoutput`,`projectcode`,`projecttitle`,`update`,`status`,`projectstatus`,`sector`,`setupinvestment`,`beneficiaryinvestment`)
values('$serviceid','$newimg1','$projectdescription','$dateofrtecreview','$dateapprovedatrpmolevel',' $dateendorsedtonpmo','$dateapprovednpmo','$datereceivedbyrpmo','$expectedoutput','$projectcode','$pro jecttitle','$update','$progress','$projectstatus','$sector','$setupinvestment','$beneficiaryinvestmen t')");
echo "<script>location.replace('admin.php?action=showallprojects')</script>";
}
答案 0 :(得分:0)
您的查询应该是这样阅读代码中的注释,并使用mysqli或PDO
$res = mysql_query("insert into appointment_detail
(`serviceid`,`picture`,`projectdescription`,`dateofrtecreview`,`dateapprovedatrpmolevel`,
`dateendorsedtonpmo`,`dateapprovednpmo`,`datereceivedbyrpmo`,`expectedoutput`,
`projectcode`,`projecttitle`,`update`,`status`,`projectstatus`,`sector`,`setupinvestment`,
`beneficiaryinvestment`)
values('$serviceid','$newimg1','$projectdescription','$dateofrtecreview',
'$dateapprovedatrpmolevel',' $dateendorsedtonpmo','$dateapprovednpmo',
'$datereceivedbyrpmo','$expectedoutput','$projectcode',
'$projecttitle','$update','$progress','$projectstatus','$sector',
'$setupinvestment','$beneficiaryinvestment')");
这是你的错误
/
'$beneficiaryinvestmen t this should be $'$beneficiaryinvestment
//$pro jecttitle' this should be this $projecttitle'
//dateapprovedatrpmol evel this should be this dateapprovedatrpmolevel