/    Sign up×
Community /Pin to ProfileBookmark

ON DUPLICATE KEY Help

Hello:

I have a query where I’m trying to insert data using the ON DUPLICATE KEY syntax.

When I run the script, I receive the following message:
FS30YF100FS30YF100Unknown column ‘a’ in ‘field list’.

Can someone help me with this error message?

Thank you in advance. If you need any other info, I’ll be happy to pass it along. I just don’t know what info you may need so I’m showing the script that produces the error message.

This is the code:

[code=php]
<?php

//session_start();
include(‘header.html’);

require_once (‘mysql_connect.php’);

$query = “SELECT a.id, a.lender_code, b.id, b.program_code, CONCAT(a.lender_code,b.program_code) AS prl FROM lender a, loan_program b
WHERE a.id=$_SESSION[lender_id] AND b.id=$_SESSION[program_id]”;

$result = @mysql_query ($query) or die (mysql_error());

if ($result) {

while($row=@mysql_fetch_array($result, MYSQL_ASSOC))
{
$lender_code = $row[‘lender_code’];
$program_code = $row[‘program_code’];
$prl = $row[‘prl’];

echo $lender_code;
echo $program_code;
echo $prl;
}
}

$query2 = “INSERT INTO test (program_id, program_code, lender_id, lender_code, prog_lend, rate, price, date, time)
VALUES (‘$_SESSION[program_id]’,’$_SESSION[program_code]’,’$_SESSION[lender_id]’,’$_SESSION[lender_code]’,’$prl’,’$_SESSION[rate1]’,’$_SESSION[price1]’, CURRENT_DATE, CURRENT_TIME),
(‘$_SESSION[program_id]’,’$_SESSION[program_code]’,’$_SESSION[lender_id]’,’$_SESSION[lender_code]’,’$prl’,’$_SESSION[rate2]’,’$_SESSION[price2]’, CURRENT_DATE, CURRENT_TIME),
(‘$_SESSION[program_id]’,’$_SESSION[program_code]’,’$_SESSION[lender_id]’,’$_SESSION[lender_code]’,’$prl’,’$_SESSION[rate3]’,’$_SESSION[price3]’, CURRENT_DATE, CURRENT_TIME),
(‘$_SESSION[program_id]’,’$_SESSION[program_code]’,’$_SESSION[lender_id]’,’$_SESSION[lender_code]’,’$prl’,’$_SESSION[rate4]’,’$_SESSION[price4]’, CURRENT_DATE, CURRENT_TIME)
ON DUPLICATE KEY UPDATE program_id=VALUES(a), program_code=VALUES(b), lender_id=VALUES(c), lender_code=VALUES(d), prog_lend=VALUES(e), rate=VALUES(f),
price=VALUES(g), date=VALUES(h), time=VALUES(i)”;
$result1 = mysql_query ($query2) or die (mysql_error());

header(“Location:admin_update_rate.php”);

?>
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @focus310 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...