I am using PHP5.1, MySQL 5.0, Apche 2.0
I am not able to insert a new record to my table.
After entering required data the process goes to
insert_oti.php
<?php
// include function files for this application
require_once('dakwa_fns.php');
session_start();
do_html_header(':: DAFTAR OTI');
$rpk= $_POST['ruj_penguatkuasa'] ;
$dtm = $_POST['tarikh_mohon'];
$dtt = $_POST['tarikh_terima'];
$dtk = $_POST['tarikh_dikeluarkan'];
$pkk = $_POST['kodkes_dipohon'];
$pke1 = $_POST['p_kodenakmen1'];
$pke2 = $_POST['p_kodenakmen2'];
$pks1 = $_POST['p_kodseks1'];
$pks2 = $_POST['p_kodseks2'];
//yang diluluskan
$lkk = $_POST['kodkes_dilulus'];
$lke = $_POST['l_kodenakmen'];
$lks = $_POST['l_kodseks'];
$bhg = $_SESSION['bahagian'];
// format date inputs to YYYY-MM-DD format
$date_elem = explode('-',$dtm);
$tm = date('Y-m-d', mktime( 0,0,0,$date_elem[1],$date_elem[0],$date_elem[2]) );
$date_elem = explode('-',$dtt);
$tt = date('Y-m-d', mktime( 0,0,0,$date_elem[1],$date_elem[0],$date_elem[2]) );
$date_elem = explode('-',$dtk);
$tk = date('Y-m-d', mktime( 0,0,0,$date_elem[1],$date_elem[0],$date_elem[2]) );
if(insert_oti($rpk, $tm, $tt, $tk, $pkk, $pke1, $pke2, $pks1, $pks2, $lkk, $lke, $lks, $bhg))
echo "REKOD: Didaftar.<br />";
else
echo "REKOD: Tidak dapat didaftar.<br />";
do_html_footer();
?>
It will call the function below to the insert:
<?php
function insert_oti($rpk, $tm, $tt, $tk, $pkk, $pke1, $pke2, $pks1, $pks2, $lkk, $lke, $lks, $bhg)
{
// insert a new oti into the database
$conn = db_connect();
// check oti does not already exist
$query = "select *
from maklumatoti
where ruj_penguatkuasa='$rpk'";
$result = $conn->query($query);
if (!$result || $result->num_rows!=0)
return false;
// insert new oti
$query = "insert into maklumatoti values ('$rpk', '$tm', '$tt','$tk','$pkk', '$pke1','$pke2','$pks1','$pks2','$lkk', '$lke', '$lks', '$bhg')";
$result = $conn->query($query);
if (!$result)
return false;
else
return true;
}
?>
Can someone look at my code and show me what I did wrong.