Php 代码在本地主机中工作正常,但在服务器中工作不正常

Php 代码在本地主机中工作正常,但在服务器中工作不正常,php,forms,Php,Forms,我需要将表单提交到数据库,我的表单及其php代码提交到localserver中的数据库中,但当我在提交后将其上载到主服务器时,会显示一个空的php文件,没有错误消息,数据也没有输入数据库, 当我为上传的图像包含php代码时,这个问题会出现,其他表单中的细节会被成功提交 作为一个学习者,所有的建议都是值得欣赏的……提前谢谢 <?php error_reporting(E_ALL); $name = $_POST['name']; $date = $_P

我需要将表单提交到数据库,我的表单及其php代码提交到localserver中的数据库中,但当我在提交后将其上载到主服务器时,会显示一个空的php文件,没有错误消息,数据也没有输入数据库, 当我为上传的图像包含php代码时,这个问题会出现,其他表单中的细节会被成功提交

作为一个学习者,所有的建议都是值得欣赏的……提前谢谢

     <?php
     error_reporting(E_ALL);
     $name = $_POST['name'];
     $date = $_POST['year']."-". $_POST['month']."-".$_POST['date'];
     $date = mysql_real_escape_string($date);
        if (isset($_POST['gender'])){
    $gender = $_POST['gender'];
           }
       if (isset($_POST['maritalstatus'])){
    $maritalstatus = $_POST['maritalstatus'];
               }
    $registerby =$_POST['registerby'];
    $livingplace =$_POST['livingplace'];
    $qualification =$_POST['quali'];
    $occupation =$_POST['occupation'];
    $income = $_POST['income'];
    $contactno =$_POST['mobno'];
    $caste =$_POST['caste'];
    $email =$_POST['email'];

     if(isset($_POST['submit']))
      {
   //Assign the paths needed to variables for use in the script 
  $filePathFull = "/public_html/www.****.com/icons/".$_FILES["imagefile"] ["name"]; 
       $filePathThumb = "/public_html/www.*****.com/icons/"; 

           //Assign the files TMP name and TYPE to variable for use in the script 
       $tmpName = $_FILES["imagefile"]["tmp_name"]; 
      $imageType = $_FILES["imagefile"]["type"]; 

//Use a switch statement to check the extension of the file type. If file type is not valid echo an error 
switch ($imageType) { 
    case $imageType == "image/gif": 
        move_uploaded_file($tmpName,$filePathFull); 
        break; 
    case $imageType == "image/jpeg": 
        move_uploaded_file($tmpName,$filePathFull);         
        break; 
    case $imageType == "image/pjpeg": 
        move_uploaded_file($tmpName,$filePathFull);         
        break;     
    case $imageType == "image/png": 
        move_uploaded_file($tmpName,$filePathFull);         
        break; 
    case $imageType == "image/x-png": 
        move_uploaded_file($tmpName,$filePathFull);         
        break;     
    default: 
        echo 'Wrong image type selected. Only JPG, PNG or GIF formats accepted!.'; 
} 

    // Get information about the image 
    list($srcWidth, $srcHeight, $type, $attr) = getimagesize($filePathFull); 

    $origRatio = $srcWidth/$srcHeight; 

    //Create the correct file type based on imagetype 
    switch($type) { 
    case IMAGETYPE_JPEG: 
            $startImage = imagecreatefromjpeg($filePathFull); 
            break; 
    case IMAGETYPE_PNG: 
            $startImage = imagecreatefrompng($filePathFull); 
            break; 
    case IMAGETYPE_GIF: 
            $startImage = imagecreatefromgif($filePathFull); 
            break; 
    default: 
            return false; 
    } 


//Get the image to create thumbnail from 
$startImage;  


$width = 150; 
$height = 150; 

if ($width/$height > $origRatio) { 
       $width = $height*$origRatio; 
}else{ 
       $height = $width/$origRatio; 
} 


 //Create the thumbnail with true colours 
 $thumbImage = imagecreatetruecolor($width, $height); 

//Generate the resized image image 
    imagecopyresampled($thumbImage, $startImage, 0,0,0,0,  $width, $height, $srcWidth, $srcHeight);     

//Generate a random number to append the filename. 
$ran = "thumb_".rand () ;     
$thumb2 = $ran.".jpg"; 


//global $thumb_Add_thumb; 

//Create the path to store the thumbnail in. 
$thumb_Add_thumb = $filePathThumb; 
$thumb_Add_thumb .= $thumb2;   

 //Create the new image and put it into the thumbnails folder. 
  imagejpeg($thumbImage, "" .$filePathThumb. "$thumb2");  
  }
   if(isset($_POST['submit']))
   {
$connection = mysql_connect("localhost","user", "pass"); 
    if(! $connection) { die('Connection Failed: ' . mysql_error()) ;}
      mysql_select_db("database") or die (error.mysql_error());
$sql = "INSERT INTO quickregister(Name,Gender,Dateofbirth,Maritalstatus,Qualification,Income,Livingplace,Caste,Contactno,Emailaddress,Registerby,picture,filePathThumb,Occupation)VALUES('".$name."','".$gender."','".$date."','".$maritalstatus."','".$qualification."','".$income."','".$livingplace."','".$caste."','".$contactno."','".$email."','".$registerby."','".$filePathFull."','".$thumb_Add_thumb."','".$occupation."')";
  $retval = mysql_query( $sql, $connection );
 if(! $retval )
 {
 die('Could not enter data' . mysql_error());
  }

 echo "<b>Your data was added to database</b>";
     }
   ?>

你的
开关
代码毫无意义。显然,您没有抓住
开关/案例
if
的重点,这是错误的:

switch ($imageType) { 
    case $imageType == "image/gif": 
        move_uploaded_file($tmpName,$filePathFull); 
        break;

    ... 

    default: 
        echo 'Wrong image type selected. Only JPG, PNG or GIF formats accepted!.'; 
} 
应该是:

switch ($imageType) { 
    case "image/gif": 
        move_uploaded_file($tmpName,$filePathFull); 
        break;

无法发送任何错误消息。发布问题时的经验法则是报告任何类型的错误日志/消息。是否启用了错误消息,是否启用了图像处理库?尝试添加此
ini\u集(“显示错误”,1)
在您报告
错误之前
@aletzo通过在显示的代码中包含错误,在服务器路径中出现错误,问题得到解决,谢谢