Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 06-20-2013, 02:08 PM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › PHP v
« Previous 1 ... 15 16 17 18 19 ... 32 Next »

[Ask] bagaima cara update databasenya...

Home General Computer Multimedia Business Lounge

Post Reply 
Tweet
Threaded Mode | Linear Mode
Ask bagaima cara update databasenya...
05-23-2012, 03:53 PM (This post was last modified: 05-24-2012 04:22 AM by adiscsi.)
Post: #1
adiscsi Offline
./Devilz 1st Cadet
Posts: 23
Joined: May 2012
Reputation: 1
Wink bagaima cara update databasenya...
numpang nanyak lagi om...

saya sudah membuat scrip unttuk upload file pdf ke dalam direktory, sementara isi file convertnya saya simpan kedalam database...

nah yang jadi permasalahannya bagaiman cara updatenya....

bingung ne mas... dari kemaren gak bisa...

ini cuplikan scrip uploadnya mas...

PHP Code:
<?php
include "config.php";
$file_Name = $_FILES['data']['name']; //get the file name
          
$str = 'abcdefghijklmnopqrstuvwxyz123456789';
        
$shuffled = str_shuffle($str);
        
$data_1   = substr($shuffled , -5); 
        
$data_2   = substr($shuffled , 0,5); 
        
$newname  = md5($data_1.$data_2);
        
$ext        = ".pdf"; 
        
$fileName =  $newname.$ext ;


$fileSize = $_FILES['data']['size']; //get the size
$tmpName  = $_FILES['data']['tmp_name'];

$outpath = preg_replace ( "/\.pdf$/" , "" , $tmpName ). ".txt" ; 
system ( "pdftotext " .  ( $tmpName ), $ret ); 
if ( 
$ret == 0 ) 
$isi2 = file_get_contents ( $outpath); 
unlink ( $outpath ); 
if ( 
$ret == 127 ) 
print 
"Could not find pdftotext tool." ; 
if ( 
$ret == 1 ) 
print 
"Could not find pdf file." ; 

$fileError = $_FILES['data']['error']; //get the error when upload

if($fileSize > 0 || $fileError == 0){ //check if the file is corrupt or error
$move = move_uploaded_file($_FILES['data']['tmp_name'], '/var/www/html/propdf/data/'.$fileName); //save image to the folder

if($move){
echo 
"<File Berhasil di upload>";
$q = "INSERT into pdf VALUES('','$fileName','$isi2','$fileName')"; //insert image property to database
$result = mysql_query($q) or die('data tidak berhasil di upload');  


} else{
echo 
"<h3>Failed! </h3>";
}
} else {
echo 
"Failed to Upload : ".$fileError;
}
?>

terima kasih sebelumnya om...[/php]
Find all posts by this user
Quote this message in a reply
06-05-2012, 05:04 PM
Post: #2
acilcrew Offline
./Devilz 1st Cadet
Posts: 1
Joined: Jun 2012
Reputation: 0
Smile RE: bagaima cara update databasenya...
(05-23-2012 03:53 PM)adiscsi Wrote:  numpang nanyak lagi om...

saya sudah membuat scrip unttuk upload file pdf ke dalam direktory, sementara isi file convertnya saya simpan kedalam database...

nah yang jadi permasalahannya bagaiman cara updatenya....

bingung ne mas... dari kemaren gak bisa...

ini cuplikan scrip uploadnya mas...

PHP Code:
<?php
include "config.php";
$file_Name = $_FILES['data']['name']; //get the file name
          
$str = 'abcdefghijklmnopqrstuvwxyz123456789';
        
$shuffled = str_shuffle($str);
        
$data_1   = substr($shuffled , -5); 
        
$data_2   = substr($shuffled , 0,5); 
        
$newname  = md5($data_1.$data_2);
        
$ext        = ".pdf"; 
        
$fileName =  $newname.$ext ;


$fileSize = $_FILES['data']['size']; //get the size
$tmpName  = $_FILES['data']['tmp_name'];

$outpath = preg_replace ( "/\.pdf$/" , "" , $tmpName ). ".txt" ; 
system ( "pdftotext " .  ( $tmpName ), $ret ); 
if ( 
$ret == 0 ) 
$isi2 = file_get_contents ( $outpath); 
unlink ( $outpath ); 
if ( 
$ret == 127 ) 
print 
"Could not find pdftotext tool." ; 
if ( 
$ret == 1 ) 
print 
"Could not find pdf file." ; 

$fileError = $_FILES['data']['error']; //get the error when upload

if($fileSize > 0 || $fileError == 0){ //check if the file is corrupt or error
$move = move_uploaded_file($_FILES['data']['tmp_name'], '/var/www/html/propdf/data/'.$fileName); //save image to the folder

if($move){
echo 
"<File Berhasil di upload>";
$q = "INSERT into pdf VALUES('','$fileName','$isi2','$fileName')"; //insert image property to database
$result = mysql_query($q) or die('data tidak berhasil di upload');  


} else{
echo 
"<h3>Failed! </h3>";
}
} else {
echo 
"Failed to Upload : ".$fileError;
}
?>

terima kasih sebelumnya om...[/php]

Nah, kayanya simple deh.. maeinin pake ID uploadnya :
PHP Code:
if($move){
echo 
"<File Berhasil di upload>";
if(isset(
$_GET['edit_id'])){
$q = mysql_query("select * from pdf where id = '$_GET[edit_id]'");
$j = mysql_num_rows($q);
if(
$j == 0){
$q = "INSERT into pdf VALUES('','$fileName','$isi2','$fileName')"; //insert image property to database
$result = mysql_query($q) or die('data tidak berhasil di upload');  
}else{
$q = "update pdf set fileName = '$fileName',isi = '$isi2', fileName2 = '$fileName' where id = '$_GET[edit_id]'"; //insert image property to database
$result = mysql_query($q) or die('data tidak berhasil di upload');  
}
} 
jangan lupa di Unlink ya kalo update, ntr filenya berceceran ga karuan... kasian spacenya.
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] tanya tentang update data? gandeso 7 305 06-08-2013 01:52 PM
Last Post: gandeso
Sad [Ask] cara buat balesan komentar berita di php superrmario 10 232 05-21-2013 01:53 AM
Last Post: ZenZ
  [Ask] cara membuat data mining pada php? Keonx 2 123 05-19-2013 06:12 PM
Last Post: Keonx
  [Solved] Tentang Cara Search Di Php wildan123456 4 127 05-15-2013 09:26 PM
Last Post: kurapika
  [Solved] gagal update query anyo_ateng 9 154 05-13-2013 01:02 PM
Last Post: anyo_ateng
  [Ask] Cara Decrypt Shell (dg Gambar) sayacupu 7 197 05-07-2013 07:52 PM
Last Post: googles
  [Solved] Cara Bikin Thumbnail Gambar Menggunakan PHP CodeSearcher 4 167 05-02-2013 04:47 PM
Last Post: CodeSearcher
  Bagaimana cara Login dengan menggunaka Privilage dauf 2 111 04-24-2013 11:44 AM
Last Post: dauf
  Cara Cepat Transfer File antar Hosting dengan php uchiha_sasuke 15 345 03-27-2013 06:59 AM
Last Post: uchiha_sasuke
  [Ask] cara mengarahkan action form ke page function region 11 238 03-25-2013 08:42 PM
Last Post: DC_Julianz

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 06-20-2013, 02:08 PM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE