php - Sql update doesn't work unless choosing a file


in this edit file i have to choose the same picture file or another picture file to be able update the rows. but i want to be able to change whichever i want without touching the other rows. any ideas over here?

include ('../ac.thumbs.php');

 if ($_GET['sil']) {
    $sil = htmlspecialchars(stripslashes($_GET['sil']));
    mysql_query("DELETE FROM CloseOut WHERE itemNO = $sil limit 1");
    echo "<h1>$sil item nolu kayit silinmistir</h1><br>";

    $edit = htmlspecialchars(stripslashes($_GET['edit']));
 $data = mysql_query("SELECT * FROM CloseOut WHERE itemNO=$edit") or die(mysql_error()); 

 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { echo "
<a href=\"edit.php?sil=$info[itemNO]\"onclick=\"return confirm('Do you really want to erase this entry?')\">[ Delete ]</a><br>
<a href=../../large.php?f=upload/".$info['resim'], $thumblarge .">
<img src=../../small.php?f=upload/".$info['resim'], $thumbsmall .">
$editresim = $info[resim];
$editisim = $info[isim];
$editalan1 = $info[alan1];
$editalan2 = $info[alan2];
$editalan3 = $info[alan3];
$editalan4 = $info[alan4];

 //Resimlerin yuklenecegin yer
 $target = "../../upload/";  
 $target1 = $target . basename( $_FILES['resim1']['name']) ; 
 //Formdan gelen bilgileri almasi icin

/////////////Formdaki bos alanlara bos bilgi kayit etmemesi icin////////////////////////

$updates = array();
if (!empty($resim))
  $updates[] = 'resim="'.mysql_real_escape_string($resim).'"';
if (!empty($isim))
  $updates[] = 'isim="'.mysql_real_escape_string($isim).'"';
if (!empty($alan1))
  $updates[] = 'alan1="'.mysql_real_escape_string($alan1).'"';
if (!empty($alan2))
  $updates[] = 'alan2="'.mysql_real_escape_string($alan2).'"';
if (!empty($alan3))
  $updates[] = 'alan3="'.mysql_real_escape_string($alan3).'"';
if (!empty($alan4))
  $updates[] = 'alan4="'.mysql_real_escape_string($alan4).'"';
$updates = implode(', ', $updates);

 //update etmesi icin
if(move_uploaded_file($_FILES['resim1']['tmp_name'], $target1)) 
mysql_query("UPDATE CloseOut SET $updates WHERE itemNO='$edit' ");
echo "Tebrikler, ". basename( $_FILES['resim1']['name']). " isimli dosya yuklendi ve database'e basariyla islendi!<br>"; 


<table width="900" border="5" class="page_speed_297636136"bordercolor="#000000">
        <td width="120" height="50" bgcolor= "545454"><b>RESIM</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>NAME</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>CATAGORY</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>QUANTITY</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>LOCATION</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>PRICE</b></td>
<form enctype="multipart/form-data" method="post" action="">
<td><input type="file" name="resim1" value="<?php echo $editresim;?>"> </td>
<td><input type="text" name="isim1" value="<?php echo $editisim;?>"> </td>
<td><input type="text" name="alan11" value="<?php echo $editalan1;?>"> </td>
<td><input type="text" name="alan21" value="<?php echo $editalan2;?>">  </td>
<td><input type="text" name="alan31" value="<?php echo $editalan3;?>"></td>
<td><input type="text" name="alan41" value="<?php echo $editalan4;?>"></td>

<td colspan="5"><center><input type="submit"></center></td>


People are also looking for solutions to the problem: php - When should the Controller get instantiated?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.