图像将上传到服务器,但不会在表中创建任何字段


Image is uploaded to the server, but no field is created in the table

我们已经将其设置为用户可以选中一个框以指示内容是成人内容。未选中的上传照片将上传并存储在数据库中,但是,如果他们选中该框以将其标记为成人,它仍会上传到服务器,但不会在表中创建任何字段。

$mature=$HTTP_POST_VARS["mature"];
if($mature=="on") {
// $adult=1; // has no function, could be useful?
}
else {
// $adult=0; // has no function, could be useful?
// ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE 
      $sql="select photo_id as a from user_pics where user_id = $_SESSION[user_id]"; 
      $result2 = mysql_query($sql); 
      $pic=mysql_num_rows($result2); 
      if($pic==0) {
// if no photos found within the database table user_pics
                     // Identify if adult or not.
                     $mature_content=$HTTP_POST_VARS["mature"];
                     if($mature_content=="on") {
                     $adult_rated=1;
                     }
                     else {
                     $adult_rated=0;
                     }
                     // Identify if adult or not.
                    $sql="insert into user_pics";
                    $sql.="(user_id";
                    $sql.=", caption";
                    $sql.=", mature";
                    $sql.=", photo_url";
                    $sql.=", medium_photos";
                    $sql.=", small_photos)";
                    $sql.=" values($_SESSION[user_id]";
                    $sql.=", '$caption'";
                    $sql.=", $adult_rated";     
                    $sql.=", '$picture_url'";       
                    $sql.=", '$med_picture_url'";       
                    $sql.=", '$small_picture_url')";
                    $result=mysql_query($sql);      
                    $photo_id = mysql_insert_id();
      } else {
// if one or more than one photo
                // Identify if adult or not.
                $mature_content=$HTTP_POST_VARS["mature"];
                if($mature_content=="on") {
                $adult_rated=1;
                }
                else {
                $adult_rated=0;
                }
                // Identify if adult or not.
                $sql="insert into user_pics";
                $sql.="(user_id";
                $sql.=", caption";
                $sql.=", mature";
                $sql.=", photo_url";
                $sql.=", medium_photos";
                $sql.=", small_photos)";
                $sql.=" values($_SESSION[user_id]";
                $sql.=", '$caption'";
                $sql.=", $adult_rated";     
                $sql.=", '$picture_url'";       
                $sql.=", '$med_picture_url'";       
                $sql.=", '$small_picture_url')";
                $result=mysql_query($sql);      
                $photo_id = mysql_insert_id();
      } 
// ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE ALBUM CODE HERE 
}

如果是$mature=="on",那么您将跳过可能将某些内容插入数据库的整个代码块。因此,如果这是真的,则不会插入任何内容。除非我误解了你在问什么。