Hi I have a problem while i am trying to add to the database i can't find where is the bug is...Pls help me ....

if($action=="insert")
{
$acknowledgement_no=$_POST['acknowledgement_no'];
$customer_id=$_POST['customer_id'];
$date_commencement=$_POST['date_commencement'];
$Plan_term=$_POST['Plan_term'];
$ledger_no=$_POST['ledger_no'];
$customer_name=$_POST['customer_name'];
$age=$_POST['age'];
$cur_address=$_POST['cur_address'];
$nominee_name=$_POST['nominee_name'];
$nominee_age=$_POST['nominee_age'];
$relation_applicant=$_POST['relation_applicant'];
$Place=$_POST['Place'];
$agent_name=$_POST['agent_name'];
$agent_code=$_POST['agent_code'];
$amount_invested=$_POST['amount_invested'];
$received_rupees=$_POST['received_rupees'];

$query5="INSERT INTO bond_print  SET ";
$query5.="acknowledgement_no='$acknowledgement_no',";
$query5.="customer_id='$customer_id',"; 
$query5.="date_commencement='$date_commencement',";
$query5.="Plan_term='$Plan_term',";
$query5.="ledger_no='$ledger_no',"; 
$query5.="customer_name='$customer_name',"; 
$query5.="age='$age',"; 
$query5.="cur_address='$cur_address',"; 
$query5.="nominee_name='$nominee_name',"; 
$query5.="nominee_age='$nominee_age',"; 
$query5.="relation_applicant='$relation_applicant',";
$query5.="Place='$Place',"; 
$query5.="agent_name='$agent_name',"; 
$query5.="agent_code='$agent_code',";
$query5.="amount_invested='$amount_invested',";
$query5.="received_rupees='$received_rupees'"; 

$result5=mysql_query($query5);
}

Recommended Answers

All 3 Replies

in my experience the key word SET is used to update a table, where here you are inserting.

The syntax i use to insert is

INSERT INTO tbl_name (column, names, in, here) VALUES ('$valueforcolumn', '$valuefornames', '$valueforin', '$valueforhere')
<?php 
$Query="INSERT INTO tbl_name". 
"(column, names, in, here) VALUES".
"('$valueforcolumn', '$valuefornames', '$valueforin', '$valueforhere')";
?>

You can use SET in a MySQL insert statement:
http://dev.mysql.com/doc/refman/5.1/en/insert.html

The best way to see what that error is, is to check for errors when you execute a query. Eg:

$result5=mysql_query($query5);
if (!$result5) {
   echo mysql_error();
}

Calling mysql_query() should automatically trigger an error. But if you have error output turned off (php.ini config value display_errors) then look into your error logs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.