更新和插入表单会删除内容

时间:2013-07-16 18:17:23

标签: php mysql insert

我有一个包含60个字段的表单。当我插入一个字段时没关系,但是当我尝试上传一张照片时,剩下的就被删除了。

要插入/更新的代码:

if(isset($_POST['update'])) {
        mysql_query ("UPDATE obras SET artista ='$artista',
        titulo = '$titulo' , fecha = '$fecha', medidas='$medidas' , medium='$medium', procedencia='$procedencia' ,
        exhibition ='$exhibition',ref_number='$refnumber' , descripcion='$descripcion',expertoname1='$expertoname1',
        expertodoc1='$expertodoc1',traduccion='$traduccion',traduccion1='$traduccion1', traduccion2='$traduccion2',
        expertoname2='$expertoname2',expertodoc2='$expertodoc2',traduccion_exp='$traduccion_exp',traduccion_exp1='$traduccion_exp1',
        traduccion_exp2='$traduccion_exp2',bibliografia='$bibliografia',c_report='$c_report',factura='$factura',ownership='$ownership',
        deposito='$deposito',pvp='$pvp',offers='$offers',marketprice='$marketprice',catalogos='$catalogos',exhibitions_publications='$exhibitions_publications',
        publicidad='$publicidad',localizacion='$localizacion',caja='$caja',permiso='$permiso',licencia='$licencia',citex_file='$citex_file',piece_tiff ='$piece_tiff',piece_tiff1 ='$piece_tiff1',
        piece_tiff2 ='$piece_tiff2',piece_tiff3 ='$piece_tiff3',piece_tiff4 ='$piece_tiff4',piece_tiff5 ='$piece_tiff5',piece_jpg ='$piece_jpg',piece_jpg1 ='$piece_jpg1',
        piece_jpg2 ='$piece_jpg2',piece_jpg3 ='$piece_jpg3',piece_jpg4 ='$piece_jpg4',piece_jpg5 ='$piece_jpg5',piece_comparativastiff ='$piece_comparativastiff',
        piece_comparativastiff1 ='$piece_comparativastiff1',piece_comparativastiff2 ='$piece_comparativasiff2',piece_comparativastiff3 ='$piece_comparativastiff3',
        piece_comparativastiff4 ='$piece_comparativastiff4',piece_comparativastiff5 ='$piece_comparativastiff5',piece_comparativasjpg ='$piece_comparativasjpg',piece_comparativasjpg1 ='$piece_comparativasjpg1',
        piece_comparativasjpg2 ='$piece_comparativasjpg2',piece_comparativasjpg3 ='$piece_comparativasjpg3',piece_comparativasjpg4 ='$piece_comparativasjpg4',
        piece_comparativasjpg5 ='$piece_comparativasjpg5',piece_resttiff ='$piece_resttiff',piece_resttiff1 ='$piece_resttiff1',
        piece_resttiff2 ='$piece_resttiff2',piece_resttiff3 ='$piece_resttiff3',piece_resttiff4 ='$piece_resttiff4',piece_resttiff5 ='$piece_resttiff5',
        piece_restjpg ='$piece_restjpg',piece_restjpg1 ='$piece_restjpg1',
        piece_restjpg2 ='$piece_restjpg2',piece_restjpg3 ='$piece_restjpg3',piece_restjpg4 ='$piece_restjpg4',piece_restjpg5 ='$piece_restjpg5',
        citex='$citex' WHERE id_obras='$id'")
        or die(mysql_error());

  }
  else{
        $sentencia = "INSERT INTO obras (artista ,titulo , fecha, medidas , medium, procedencia ,exhibition ,ref_number , descripcion,
        expertoname1,expertodoc1,traduccion,traduccion1, traduccion2,expertoname2,expertodoc2,traduccion_exp,
        traduccion_exp1,traduccion_exp2,bibliografia,c_report,factura,ownership,
        deposito,pvp,offers,marketprice,catalogos,exhibitions_publications,publicidad,localizacion,caja,permiso,licencia,
        citex_file,piece_tiff,piece_tiff1,piece_tiff2,piece_tiff3,piece_tiff4,piece_tiff5,piece_jpg,piece_jpg1,
        piece_jpg2,piece_jpg3,piece_jpg4,piece_jpg5,piece_comparativastiff,piece_comparativastiff1
        ,piece_comparativastiff2,piece_comparativastiff3,piece_comparativastiff4,piece_comparativastiff5,piece_comparativasjpg
        ,piece_comparativasjpg1,piece_comparativasjpg2,piece_comparativasjpg3,piece_comparativasjpg4,piece_comparativasjpg5
        ,piece_resttiff,piece_resttiff1,piece_resttiff2,piece_resttiff3,piece_resttiff4,piece_resttiff5,piece_restjpg
        ,piece_restjpg1,piece_restjpg2,piece_restjpg3,piece_restjpg4,piece_restjpg5,citex)

        VALUES ('".$_REQUEST['artista']."','".$_REQUEST['titulo']."','".$_REQUEST['date']."','".$_REQUEST['medidas']."','".$_REQUEST['medium']."'
        ,'".$_REQUEST['procedencia']."','".$_REQUEST['exhibition']."','".$_REQUEST['refnumber']."','".$_REQUEST['desciption']."'
        ,'".$_REQUEST['experto1']."','$expertodoc1','$traduccion','$traduccion1','$traduccion2','".$_REQUEST['experto2']."','$expertodoc2',
        '$traduccion_exp','$traduccion_exp1','$traduccion_exp2','".$_REQUEST['bibliografia']."'
        ,'$c_report','$factura','".$_REQUEST['owners_share']."','$deposito','".$_REQUEST['pvp']."','".$_REQUEST['offers']."','".$_REQUEST['marketprice']."'
        ,'".$_REQUEST['catalogos']."','".$_REQUEST['exhibitions_publications']."','".$_REQUEST['publicidad']."','".$_REQUEST['localizacion']."'
        ,'".$_REQUEST['caja']."','$permiso','$permiso_doc','$citex_doc','$piece_tiff','$piece_tiff1','$piece_tiff2','$piece_tiff3','$piece_tiff4','$piece_tiff5'
        ,'$piece_jpg','$piece_jpg1','$piece_jpg2','$piece_jpg3','$piece_jpg4','$piece_jpg5','$piece_comparativastiff','$piece_comparativastiff1'
        ,'$piece_comparativastiff2','$piece_comparativastiff3','$piece_comparativastiff4','$piece_comparativastiff5','$piece_comparativasjpg'
        ,'$piece_comparativasjpg1','$piece_comparativasjpg2','$piece_comparativasjpg3','$piece_comparativasjpg4','$piece_comparativasjpg5'
        ,'$piece_resttiff','$piece_resttiff1','$piece_resttiff2','$piece_resttiff3','$piece_resttiff4','$piece_resttiff5','$piece_restjpg'
        ,'$piece_restjpg1','$piece_restjpg2','$piece_restjpg3','$piece_restjpg4','$piece_restjpg5','$citex')";
        $resultado=mysql_query($sentencia) or die('Error en:'.$sentencia.'::'. mysql_error());
  }

仅插入除piece_*以外的所有数据。我不知道该怎么做或发生了什么。

0 个答案:

没有答案