lawang code

lawang Code


Tanyakan kode disini

bagaimana mengatasi ini: Duplicate entry 'IMG002' for key 'PRIMARY'

ditanyakan oleh Muh. Rezky Anugerah. A 2 tahun yang lalu
$carikode = mysql_query("select max(id) from foto") or die (mysql_error());
  $datakode = mysql_fetch_array($carikode);
  $jumlah_data = mysql_num_rows($carikode);
  if ($datakode) {
   $nilaikode = substr($jumlah_data[0], 1);
   $kode = (int) $nilaikode;
   $kode = $jumlah_data + 1;
   $hasilkode = "IMG".str_pad($kode, 3, "0", STR_PAD_LEFT);
  } else {
   $hasilkode = "IMG001";
  }
$sql = "INSERT INTO foto (id,gambar,keterangan) values ('$hasilkode','$fileName','".$_POST['kete']."')";
mysql_query($sql) or die (mysql_error());
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}

Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 6
X 48
X 14
X 10
X 1
X 5
X 4
X 18
X 10

Bantuan

Help

Feedback

Help