carwin/smplst — Issue #1: Undefined Variable error for first list item.
Author: carwin
Created: 2011-12-29 01:09:12+00:00
State: open

For some reason the variable $new_id isn't being set. I'm sure this is an oversight on my part. Adding this here as an issue just so I remember it.

save_new_record() looks like this:

function save_new_record($text, $lid){
//Calculate how many items there are now
$query1 = "SELECT recordID FROM records WHERE recordID = (SELECT MAX(recordID) FROM records);";
$result1 = mysql_query($query1);
while($row = mysql_fetch_array($result1)){
if(isset($new_id)){
$new_id = 0;
}
$new_id = end($row) + 1;
}
$query2 = "INSERT INTO records (recordID, recordText, recordListingID, lid) VALUES";
$query2 .= '("'.$new_id.'", "'.$text.'", "'.$new_id.'", "'.$lid.'");';
return mysql_query($query2);
exit;
}