Query Update tidak di proses

wawan · May 3, 2012
Siang bli, mau tanya bli
pada query update saya salah dibagian mana ya bli. kok saat proses update dia gak memproses.
mohon di koreksi bli.
<div class="wawan-panel grid_7">
                	<div class="wawan-panel-header">
                    	<span class="wawan-i-24 i-list">Form Upload File Informasi Berkala</span>
                    </div>
                    <div class="wawan-panel-body">
					<?php
 
						if (isset($_POST['frminput']) && $_POST['btnTambah'] == "Submit")
						{
							$kategori = "Berkala";
							$unit = "sdm";
							$tanggal;
							$informasi=ucwords($_POST['informasi']);
							$nama_file=$_FILES['file_berkala']['name'];
							$ukuran=$_FILES['file_berkala']['size'];
 
							if (trim($informasi)=="") {
								echo "<script>alert('Nama Informasi masih kosong, ulangi kembali.');</script>";
							}
							elseif (trim($nama_file)=="") {
								echo "<script>alert('File masih kosong, ulangi kembali.');</script>";
 
							}else{
 
								$uploaddir='./files/';
								$alamatfile=$uploaddir.$nama_file;
 
								if (move_uploaded_file($_FILES['file_berkala']['tmp_name'],$alamatfile))
								{
									echo "<script>alert('Data Anda berhasil diupload.');</script>";
 
									$upload=mysql_db_query($dbs,"INSERT INTO file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file','$ukuran','$alamatfile','$tanggal','$informasi','$kategori','$unit')");
 
								}else{
									echo "<script>alert('Proses upload gagal, kode error = {$_FILES['location']['error']}');</script>";
								}
							}
 
						}
						else
						{
							unset($_POST['frminput']);
						}
 
 
						//*** Delete ***//
						if($_GET["Action"] == "Del")
						{
							$strSQL = "DELETE FROM file_upload WHERE Id = '".$_GET["Id"]."' ";
							$objQuery = mysql_query($strSQL);
							if(!$objQuery)
							{
								echo "Error Delete [".mysql_error()."]";
							}
							//header("location:$_SERVER[PHP_SELF]");
							//exit();
						}
 
 
						//*** Update ***//
 
					?>
 
                    	<form class="wawan-form"  enctype="multipart/form-data" action="dashboard.php?page=berkala" method="post" >
                    		<div class="wawan-form-inline">
					<input class="wawan-textinput" style="width:80%;" name="statpos" type="hidden" value="frminput"/>
                    			<div class="wawan-form-row">
                                    <label>Nama Informasi</label>
                                    <div class="wawan-form-item large">
                                    	<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" placeholder="Nama informasi"/>
                                    </div>
                                </div>
                    			<div class="wawan-form-row">
                                    <label>File Upload</label>
                                    <div class="wawan-form-item large">                              	
                                        <input type="file" name="file_berkala" class="required" />
                                    </div>
                                </div>
                    		</div>
                    		<div class="wawan-button-row">
                    			<input type="submit" name="btntambah" value="Submit" class="wawan-button red" />
                    			<input type="reset" value="Reset" class="wawan-button gray" />
                    		</div>
                    	</form>
                    </div>
				</div>
 
				<div class="wawan-panel grid_7">
                	<div class="wawan-panel-header">
                    	<span class="wawan-i-24 i-table-1">Daftar File Informasi Berkala</span>
                    </div>
                    <div class="wawan-panel-body">
                        <table class="wawan-datatable-fn wawan-table">
                            <thead>
                                <tr>
									<th>No.</th>
                                    <th>Nama Informasi</th>
                                    <th>Nama File</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
								<?php
									$no=1;
									$sql = "SELECT * FROM file_upload where kategori='Berkala' ORDER BY tgl_upload";
									$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
									while ($data=mysql_fetch_array($qry)) {
 
								?>
                                <tr class="gradeX">
									<td><?php echo $no ?></td>
                                    <td><?php echo $data['informasi']; ?></td>
                                    <td><?php echo $data['nama_file']; ?></td>
                                    <td class="center">
									<a id="wawan-form-dialog-mdl-btn-<?php echo $no ?>" href="<?=$_SERVER["PHP_SELF"];?>?page=berkala&Action=Edit&Id=<?php echo $data['Id']; ?>&info=<?php echo $data['informasi']; ?>" >Edit</a> - <a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?page=berkala&Action=Del&Id=<?php echo $data['Id'];?>';}">Hapus</a>
 
 
									</td>
                                </tr>
								<?php
									$no++;
									}
								?>
 
                            </tbody>
 
                        </table>
 
 
 
									<?php
										if ($_GET['Action'] == "Edit") {
											$informasi = $_GET['info'];
											$Id = $_GET['Id'];
 
											$sqlupdate="select * from file_upload where id ='$Id'";
											$qryupdate=mysql_query($sqlupdate,$koneksi) or die ("Gagal query".mysql_error());
											$data=mysql_fetch_array($qryupdate);
 
										/*if(isset($_GET["Edit"]) and $_GET["Edit"] == $no)
										{*/
									?>
							<?php
							if($_POST["statpos"] == "frmupdate")
							/*if (isset($_POST['frmupdate']))
							if (isset($_POST['frmupdate']) && $_POST['statpos'] == "frmupdate")*/
							{
								$Id = $_POST['Id'];
								$kategori_update = "Berkala";
								$unit_update = "sdm";
								$tanggal;
								$informasi_update = ucwords($_POST['informasi']);
								$nama_file_update = $_FILES['file_berkala_update']['name'];
								$ukuran_update = $_FILES['file_berkala_update']['size'];
 
 
								if (trim($informasi_update)=="") {
									echo "<script>alert('Nama Informasi masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($nama_file_update)=="") {
									echo "<script>alert('File Upload belum dipilih, ulangi kembali.');</script>";
								}
								else {
									$uploaddir_update='./files/';
									$alamatfile_update=$uploaddir_update.$nama_file_update;
 
									if (move_uploaded_file($_FILES['file_berkala_update']['tmp_name'],$alamatfile_update))
									{
										echo "<script>alert('Update data Anda berhasil diupload.');</script>";
										$update=mysql_db_query($dbs,"UPDATE file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file_update','$ukuran_update','$alamatfile_update','$tanggal','$informasi_update','$kategori_update','$unit_update')");
									}else{
										echo "<script>alert('Proses update gagal, kode error = {$_FILES['location']['error']}');</script>";
									}
 
 
								}
							}
							else
							{
								unset($_POST['frmupdate']);
							}
 
							?>
									<div id="wawan-form-dialog">
										<form class="wawan-form" action="dashboard.php?page=berkala" method="post">
												<input class="wawan-textinput" style="width:80%;" name="statpos" type="hidden" value="frmupdate"/>
											<div class="wawan-form-inline">
												<div class="wawan-form-row">
													<label>Nama Informasi</label>
													<div class="wawan-form-item large">
														<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" value="<?php echo $data['informasi']; ?>"/>
													</div>
												</div>
												<div class="wawan-form-row">
													<label>File Upload</label>
													<div class="wawan-form-item large">
														<input type="file" name="file_berkala_update" class="required" />
													</div>
												</div>
											</div>
                    						<div class="wawan-button-row">
                    							<input type="submit" name="Submit" value="Update" class="wawan-button green" />
                    						</div>
										</form>
									</div>
							<?php
								}
							?>
 
 
                    </div>    	
                </div>

terima kasih bli ellyx
Silahkan login untuk menjawab!
0
Loading...
wawan · May 3, 2012 · 0 Suka · 0 Tidak Suka
berikut struktur tabelnya bli..
--
-- Table structure for table `file_upload`
--

CREATE TABLE IF NOT EXISTS `file_upload` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `nama_file` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `ukuran` varchar(10) COLLATE latin1_general_ci NOT NULL,
  `url` varchar(10) COLLATE latin1_general_ci NOT NULL,
  `tgl_upload` date NOT NULL,
  `informasi` text COLLATE latin1_general_ci NOT NULL,
  `kategori` varchar(25) COLLATE latin1_general_ci NOT NULL,
  `unit` varchar(50) COLLATE latin1_general_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=15 ;
0
Loading...
Ellyx Christian · May 7, 2012 · 0 Suka · 0 Tidak Suka
saya rasa karena kamu salah membuat query update, query update bukan

UPDATE file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file_update','$ukuran_update','$alamatfile_update','$tanggal','$informasi_update','$kategori_update','$unit_update')

tapi

UPDATE file_upload set nama_file='$nama_file_update',
ukuran='$ukuran_update',url='$alamatfile_update', tgl_upload='$tanggal',informasi='$informasi_update', kategori='$kategori_update',unit='$unit_update' where Id='$Id';