drh19790711 2014-10-01 02:47
浏览 43

插入目录文件夹中的图像不在数据库中?

image inserted in directory folder not in database? please see the code, the image can be viewed in the folder but not in database the pc.gif is inserted instead on the command else the filename is executed on the command but the else is executed? the first command is proper why the second command is executed instead.

    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>";
   }
  • 写回答

1条回答 默认 最新

  • duangan6636 2014-10-01 03:04
    关注

    your query should be like this Read the comment in the code, and use mysqli or 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')");
    

    These were your mistake

    /

    '$beneficiaryinvestmen t this should be $'$beneficiaryinvestment
    
        //$pro jecttitle' this should be this $projecttitle'
        //dateapprovedatrpmol evel this should be this dateapprovedatrpmolevel
    
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路