Jump to content

INSERT help


hbradshaw

Recommended Posts

Hello:

 

I'm trying to insert data into a table.  When I run the script, my table is empty but I receive no error messages.  Can someone lend another pair of eyes and help me out?  The SELECT part and the echo part of the query works.  The values in the table from the SELECT statement do echo onto the screen.  When I try to INSERT the values into another table, I come up empty.

 

Thank you for the help.

 

Here's the script:

<?php

require_once ('mysql_connect.php');

$query = "SELECT a.lender_code, b.program_code, CONCAT(a.lender_code,b.program_code) AS prl FROM lender a, loan_program b";

$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;


$query1 = "INSERT INTO test (lender_code, program_code, prog_lend) 
           VALUES ('$lender_code','$program_code','$prl')";



}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/45070-insert-help/
Share on other sites

$query1 = "INSERT INTO test (lender_code, program_code, prog_lend)

          VALUES ('$lender_code','$program_code','$prl')";

 

needs to be

 

$query1 = mysql_query("INSERT INTO test (lender_code, program_code, prog_lend)

          VALUES ('$lender_code','$program_code','$prl')") or die ('Error inserting: '.mysql_error());

 

 

 

Regards

Liam

Link to comment
https://forums.phpfreaks.com/topic/45070-insert-help/#findComment-218808
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.