Advertisement
GWibisono

kondisikan saja

Jan 27th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. // code A
  3. //include("fungsi_koneksi.php");
  4. $host="localhost";
  5. $user="root";
  6. $pass="";
  7. $db="work_mujur";
  8.  
  9. $mysqli = new mysqli($host, $user, $pass, $db);
  10. if (mysqli_connect_errno()) {
  11.     printf("Connect failed: %s\n", mysqli_connect_error());
  12.     exit();
  13. }
  14. else{
  15.  //echo 'Koneksi berhasil';
  16.  // printf("<br/>Host information: %s\n", $mysqli-> host_info);
  17. }
  18. // end of code A
  19.  
  20. // code B
  21. $lokasi_file = $_FILES['pp']['tmp_name'];
  22. $tipe_file = $_FILES['pp']['type'];
  23. $nama_file = $_FILES['pp']['name'];
  24. $direktori = "image/$nama_file";
  25. // end of code B
  26.  
  27. //if (!empty($lokasi_file)) {
  28. $aksi=upload($lokasi_file,$direktori);
  29. if (!$aksi) {
  30.     echo "maaf gagal memasukan gambar";exit();
  31. }
  32. // code C
  33. //$koneksi = koneksi_db();
  34. $sql = "insert into dtimage values (null,'$nama_file')";
  35. //$aksi = mysql_query($sql,$koneksi);
  36. $q=$mysqli->query($sql);
  37. if(!$q){
  38.     echo 'Wrong SQL: ' . $sql . ' Error: ' . $conn->error ;
  39.     exit();
  40.  }
  41. // end of code C
  42.  
  43. // code D
  44. //if (!$aksi) {
  45. //echo "maaf gagal memasukan gambar";
  46. //}else{
  47. echo "gambar berhasil di upload<br>";
  48. echo "untuk melihatnya silakan klik <a href='view_image.php'>Link ini</a>";
  49. //}
  50. // end of code D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement