Hi April,
It might be that as you've already called mysql_insert_id(), the last inserted value might not be stored in in any more when you call it a second time. You could try changing your code to this between lines 105 and 125:
mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$recordNum = mysql_insert_id();
// adopt temp uploads
adoptUploads($tableName, $preSaveTempId, $recordNum);
removeExpiredUploads(); // erase old expired uploads
// display thanks message and clear form
$errorsAndAlerts = "Thanks, we've added your record!";
$_REQUEST = array();
$preSaveTempId = uniqid('x');
// send message
$placeholders = array(
'user.email' => $_REQUEST['email'],
'user.fullname' => $_REQUEST['name'],
'content' => $_REQUEST['content'],
'contestAdminUrl' => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=$tableName&action=edit&num=" . $recordNum,
So I've removed the line that resets the $recordNum value to null, and I'm using that value on the end of the contestAdminUrl value.
Another way around this issue would be to insert the data using CMS Builders mysql_insert function:
if (!@$errorsAndAlerts) {
$insertArray = array(
'createdDate' => date('Y-m-d H:i:s'),
'createdByUserNum' => $CURRENT_USER['num'],
'updatedDate' => date('Y-m-d H:i:s'),
'updatedByUserNum' => $CURRENT_USER['num'] ),
'date' => date('Y-m-d H:i:s'),
'hidden' =>'1',
'name' => $_REQUEST['name'],
'content' => $_REQUEST['content'],
'email' => $_REQUEST['email'],
'category' => $_REQUEST['category'] ,
'title' => $_REQUEST['title'],
);
$recordNum = mysql_insert($tableName, $insertArray, true);
// adopt temp uploads
adoptUploads($tableName, $preSaveTempId, $recordNum);
removeExpiredUploads(); // erase old expired uploads
// display thanks message and clear form
$errorsAndAlerts = "Thanks, we've added your record!";
$preSaveTempId = uniqid('x');
// send message
$placeholders = array(
'user.email' => $_REQUEST['email'],
'user.fullname' => $_REQUEST['name'],
'content' => $_REQUEST['content'],
'contestAdminUrl' => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=$tableName&action=edit&num=" . $recordNum,
);
The good thing about this function is it automatically parses the data to make it safe for MySQL, and if you pass in true as the third value, it will automatically insert a default value into any fields with missing data.
Let me know if you have any questions.
Thanks!
Greg
Greg Thomas
PHP Programmer - interactivetools.com