hbradshaw Posted March 31, 2007 Share Posted March 31, 2007 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 More sharing options...
shocker-z Posted March 31, 2007 Share Posted March 31, 2007 $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 More sharing options...
hbradshaw Posted March 31, 2007 Author Share Posted March 31, 2007 Thank you very much for the help. It worked. Link to comment https://forums.phpfreaks.com/topic/45070-insert-help/#findComment-218809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.