Hello:
I'm trying to write a query which will update values after they were inserted.
Once a set of rates is inputed for a new lender and program, the rates will be inserted into the table. Later, if there is a new set of rates for the program/lender which was just inserted, I want to update those rates.
When I run the query I get the following error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(program_id = '1', program_code = '30YFA', lender_id = '1', lender_' at line 7
Thank you for the help.
<?php
//session_start();
include('header.html');
require_once ('mysql_connect.php');
$query2 = "INSERT INTO rates (program_id, program_code, lender_id, lender_code, rate, price, date, time)
VALUES ('$_SESSION[program_id]','$_SESSION[program_code]','$_SESSION[lender_id]','$_SESSION[lender_code]','$_SESSION[rate1]','$_SESSION[price1]', CURRENT_DATE, CURRENT_TIME),
('$_SESSION[program_id]','$_SESSION[program_code]','$_SESSION[lender_id]','$_SESSION[lender_code]','$_SESSION[rate2]','$_SESSION[price2]', CURRENT_DATE, CURRENT_TIME),
('$_SESSION[program_id]','$_SESSION[program_code]','$_SESSION[lender_id]','$_SESSION[lender_code]','$_SESSION[rate3]','$_SESSION[price3]', CURRENT_DATE, CURRENT_TIME),
('$_SESSION[program_id]','$_SESSION[program_code]','$_SESSION[lender_id]','$_SESSION[lender_code]','$_SESSION[rate4]','$_SESSION[price4]', CURRENT_DATE, CURRENT_TIME)
ON DUPLICATE KEY UPDATE
(program_id = $_SESSION[program_id], program_code = $_SESSION[program_code], lender_id = $_SESSION[lender_id],
lender_code = $_SESSION[lender_code], rate = $_SESSION[rate1], price=$_SESSION[price1], date = CURRENT_DATE, CURRENT_TIME),
(program_id = $_SESSION[program_id], program_code = $_SESSION[program_code], lender_id = $_SESSION[lender_id],
lender_code = $_SESSION[lender_code], rate = $_SESSION[rate2], price=$_SESSION[price2], date = CURRENT_DATE, CURRENT_TIME),
(program_id = $_SESSION[program_id], program_code = $_SESSION[program_code], lender_id = $_SESSION[lender_id],
lender_code = $_SESSION[lender_code], rate = $_SESSION[rate3], price=$_SESSION[price3], date = CURRENT_DATE, CURRENT_TIME),
(program_id = $_SESSION[program_id], program_code = $_SESSION[program_code], lender_id = $_SESSION[lender_id],
lender_code = $_SESSION[lender_code], rate = $_SESSION[rate4], price=$_SESSION[price4], date = CURRENT_DATE, CURRENT_TIME)";
$result2 = mysql_query ($query2) or die (mysql_error());
?>