Jump to content

Recommended Posts

when i run this code, it keep on looping and insert data into my database. What's wrong?

<title>E Claim</title>
<?php
session_start();
$host = 'localhost';
$user = 'root';
$password = 'admin';
$dbase = 'eclaim';

$dblink = mysql_connect($host,$user,$password);
mysql_select_db($dbase,$dblink);

$staff_no    = $_POST['staff_no'];
$address1	=$_POST['address1'];
$address2	=$_POST['address2'];
$address3	=$_POST['address3'];
$jenis_kenderaan	=$_POST['jenis_kenderaan'];
$kenderaan_no	=$_POST['kenderaan_no'];
$cc	=$_POST['cc'];
$status	=$_POST['status'];
$tarikh	=$_POST['tarikh'];
$perjalanan	=$_POST['perjalanan'];
$masa       =$_POST['masa'];
$km     	=$_POST['km'];
$tol	=$_POST['tol'];
$parking	=$_POST['parking'];
$elauan	=$_POST['elauan'];
$tujuan	=$_POST['tujuan'];

while (tarikh !=NULL) {

$query= "INSERT INTO claim (staff_no,address1,address2,address3,jenis_kenderaan,kenderaan_no,cc,status,tarikh,perjalanan,masa,km,tol,parking,elauan,tujuan) VALUES ('$staff_no', '$address1','$address2','$address3','$jenis_kenderaan','$kenderaan_no','$cc','$status','$tarikh','$perjalanan','$masa','$km','$tol','$parking','$elauan','$tujuan') ";
$result = mysql_query($query,$dblink);

}

$query1 = "Select claim.staff_no,user.staff_no,user.department from claim,user where user.staff_no = user.staff_no ";
$result1 = mysql_query($query1,$dblink);
$myrow1 = mysql_fetch_row($result1);
$no = "EC/ ";

$department =$myrow1[2] ;
if (department == 'Generating Facility 1')
{
$body="<em>HTML</em> formatted <strong>Message</strong>";

//$headers = "From: administrator@eclaim.com \r\n";
$headers = "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";
mail("june@kaparenergy.com.my", "Lubrication", $body, $headers);

$query2 = "Select gf1,id from runningno ";
$result2 = mysql_query($query2,$dblink);
$myrow2 = mysql_fetch_row($result2);
//echo "00"."$myrow2[0]"." / ";
$query3 ="update runningno set id=id+1, gf1=gf1+1";
$result3 = mysql_query($query3,$dblink);
$no = $no . "GF1 / 0".$myrow2[0]. "/0".$myrow2[1];

}
else 
{
}

while (tarikh !=NULL)
{
$query13 = "UPDATE claim SET tran_id='$no' WHERE id = '$id' ";
$result13 = mysql_query($query13,$dblink);
}
$query40= "Select tran_id from claim ";
$result40 = mysql_query($query40,$dblink);
$myrow40 = mysql_fetch_row($result40);
echo "$myrow40[0]";

?>

Link to comment
https://forums.phpfreaks.com/topic/87169-error/
Share on other sites

Backup a little here. What kind of form element is tarikh? A textarea, checkboxes, something else?

 

Also, at the very beginning of your PHP code, try putting the following lines. Then fill out the form, click submit, and see what it prints out.

print_r($_POST);exit;

Link to comment
https://forums.phpfreaks.com/topic/87169-error/#findComment-446188
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.