Senin, 24 Juni 2024

setWA dan setEMAIL

 <?php
require_once"koneksivar.php";

$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
  trigger_error('Database connection failed: '  . $conn->connect_error, E_USER_ERROR);
}
?>

<?php
function selWaktu($tanggal){
$tanggal_1 = date_create($tanggal);
$tanggal_2 = date_create();
$selisih  = date_diff( $tanggal_1, $tanggal_2 );
$sisa=($selisih->days);
return $sisa." Hari";
}
function addWaktu($conn,$id_anggota){
$tanggal=date("Y-m-d");
$tanggl_berakhir= date('Y-m-d', strtotime($tanggal. ' + 30 days'));
echo $sql = "update `tb_anggota` set `tanggal_berakhir`='$tanggl_berakhir',status='Aktif' where `id_anggota`='$id_anggota'";
process($conn, $sql);
}

function setWA($ph){
$x="https://wa.me/$ph?text=I'm%20interested%20in%20your%20activity%20for%20today%20";
$x="<a href='$x' target='_blank'>$ph</a>";
return $x;
}
function setEmail($email){
$x="<a href='$email' target='_blank'>$email</a>";
return $x;
}

function terbilang($i){
  $huruf = array("", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", "Delapan", "Sembilan", "Sepuluh", "Sebelas");
  if ($i < 12) return " " . $huruf[$i];
  elseif ($i < 20) return terbilang($i - 10) . " Belas";
  elseif ($i < 100) return terbilang($i / 10) . " Puluh" . terbilang($i % 10);
  elseif ($i < 200) return " Seratus" . terbilang($i - 100);
  elseif ($i < 1000) return terbilang($i / 100) . " Ratus" . terbilang($i % 100);
  elseif ($i < 2000) return " Seribu" . terbilang($i - 1000);
  elseif ($i < 1000000) return terbilang($i / 1000) . " Ribu" . terbilang($i % 1000);
  elseif ($i < 1000000000) return terbilang($i / 1000000) . " Juta" . terbilang($i % 1000000);    
}
?>

<?php
function RP($rupiah){return number_format($rupiah,"2",",",".");}
?>
<?php
function WKT($sekarang)
{
$tanggal = substr($sekarang, 8, 2) + 0;
$bulan = substr($sekarang, 5, 2);
$tahun = substr($sekarang, 0, 4);

$judul_bln = array(1 => "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
$wk = $tanggal . " " . $judul_bln[(int)$bulan] . " " . $tahun;
return $wk;
}

function WKTP($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,2,2);

$judul_bln=array(1=> "Jan", "Feb", "Mar", "Apr", "Mei","Jun", "Jul", "Agu", "Sep","Okt", "Nov", "Des");
$wk=$tanggal." ".$judul_bln[(int)$bulan]."'".$tahun;
return $wk;
}
?>
<?php
function BAL($tanggal){
$arr=split(" ",$tanggal);
if($arr[1]=="Januari"){$bul="01";}
else if($arr[1]=="Februari"){$bul="02";}
else if($arr[1]=="Maret"){$bul="03";}
else if($arr[1]=="April"){$bul="04";}
else if($arr[1]=="Mei"){$bul="05";}
else if($arr[1]=="Juni"){$bul="06";}
else if($arr[1]=="Juli"){$bul="07";}
else if($arr[1]=="Agustus"){$bul="08";}
else if($arr[1]=="September"){$bul="09";}
else if($arr[1]=="Oktober"){$bul="10";}
else if($arr[1]=="November"){$bul="11";}
else if($arr[1]=="Nopember"){$bul="11";}
else if($arr[1]=="Desember"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>

<?php
function BALP($tanggal){
$arr=split(" ",$tanggal);
if($arr[1]=="Jan"){$bul="01";}
else if($arr[1]=="Feb"){$bul="02";}
else if($arr[1]=="Mar"){$bul="03";}
else if($arr[1]=="Apr"){$bul="04";}
else if($arr[1]=="Mei"){$bul="05";}
else if($arr[1]=="Jun"){$bul="06";}
else if($arr[1]=="Jul"){$bul="07";}
else if($arr[1]=="Agu"){$bul="08";}
else if($arr[1]=="Sep"){$bul="09";}
else if($arr[1]=="Okt"){$bul="10";}
else if($arr[1]=="Nov"){$bul="11";}
else if($arr[1]=="Nop"){$bul="11";}
else if($arr[1]=="Des"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>

<?php
function process($conn,$sql){
$s=false;
$conn->autocommit(FALSE);
try {
  $rs = $conn->query($sql);
  if($rs){
    $conn->commit();
    $last_inserted_id = $conn->insert_id;
  $affected_rows = $conn->affected_rows;
   $s=true;
  }

catch (Exception $e) {
echo 'fail: ' . $e->getMessage();
   $conn->rollback();
}
$conn->autocommit(TRUE);
return $s;
}

function getJum($conn,$sql){
  $rs=$conn->query($sql);
  $jum= $rs->num_rows;
$rs->free();
return $jum;
}

function getField($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$d= $rs->fetch_assoc();
$rs->free();
return $d;
}

function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);
//foreach($arr as $row) {
//  echo $row['nama_kelas'] . '*<br>';
//}
$rs->free();
return $arr;
}

function getParkir($conn,$kode){
$field="nama_parkir";
$sql="SELECT `$field` FROM `tb_parkir` where `idp`='$kode'";
$rs=$conn->query($sql);
$rs->data_seek(0);
$row = $rs->fetch_assoc();
$rs->free();
    return $row[$field];
}
?>



Selasa, 04 Juni 2024

Error: MySQL shutdown unexpectedly.

 

Semua pasti bisA Nangis...jika ada pesan kesalahan berikut
Mysql pada XAMPPP Control Panel (localhost/phpmyadmin) GAGAL RUN , dengan pesan



7:33:28 AM  [mysql] Error: MySQL shutdown unexpectedly.
7:33:28 AM  [mysql] This may be due to a blocked port, missing dependencies, 
7:33:28 AM  [mysql] improper privileges, a crash, or a shutdown by another method.
7:33:28 AM  [mysql] Press the Logs button to view error logs and check
7:33:28 AM  [mysql] the Windows Event Viewer for more clues
7:33:28 AM  [mysql] If you need more help, copy and post this
7:33:28 AM  [mysql] entire log window on the forums

Dan pada mysql_error.log muncul pesan berikut:

2024-06-04 18:48:00 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2024-06-04 18:48:00 0 [Note] InnoDB: Uses event mutexes
2024-06-04 18:48:00 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-06-04 18:48:00 0 [Note] InnoDB: Number of pools: 1
2024-06-04 18:48:00 0 [Note] InnoDB: Using SSE2 crc32 instructions
2024-06-04 18:48:00 0 [Note] InnoDB: Initializing buffer pool, total size = 4G, instances = 8, chunk size = 128M
2024-06-04 18:48:00 0 [Note] InnoDB: Completed initialization of buffer pool
2024-06-04 18:48:00 0 [ERROR] InnoDB: The Auto-extending innodb_system data file 'C:\xampp\mysql\data\ibdata1' is of a different size 768 pages than specified in the .cnf file: initial 6400 pages, max 0 (relevant if non-zero) pages!
2024-06-04 18:48:00 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-06-04 18:48:01 0 [Note] InnoDB: Starting shutdown...
2024-06-04 18:48:01 0 [ERROR] Plugin 'InnoDB' init function returned error.
2024-06-04 18:48:01 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-06-04 18:48:01 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-06-04 18:48:01 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2024-06-04 18:48:01 0 [ERROR] Aborting


SOLUSI:
backup file my.ini yang lama(C:\xampp\mysql\bin\my.ini), lalu isinya ganti dengan ini semua:

 

[client] 
port=3306
socket="C:/xampp/mysql/mysql.sock"
 
default-character-set=utf8mb4
[mysqld]
port=3306
socket="C:/xampp/mysql/mysql.sock"
basedir="C:/xampp/mysql"
tmpdir="C:/xampp/tmp"
datadir="C:/xampp/mysql/data"
pid_file="mysql.pid" 
key_buffer=16M
max_allowed_packet=1M
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
log_error="mysql_error.log" 
plugin_dir="C:/xampp/mysql/lib/plugin/" 
server-id =1
 
innodb_data_home_dir="C:/xampp/mysql/data"
innodb_data_file_path=ibdata1:10M:autoextend
innodb_log_group_home_dir="C:/xampp/mysql/data" 
innodb_buffer_pool_size=16M 
innodb_log_file_size=5M
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
innodb_lock_wait_timeout=50 
sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION
log_bin_trust_function_creators=1

character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
[mysqldump]
max_allowed_packet=16M

[mysql] 
[isamchk]
key_buffer=20M
sort_buffer_size=20M
read_buffer=2M
write_buffer=2M

[myisamchk]
key_buffer=20M
sort_buffer_size=20M
read_buffer=2M
write_buffer=2M

[mysqlhotcopy]


Selisih Waktu Berjalan

Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...