Strange behavior with my insert below. I pass vars to this PHP to do an insert into a table. Most of the time it works. But sometimes I get multiple duplicate entries or a blank entry followed by the correct entry.
here is my php:
include_once ('db_connection.php');//Including our DB Connect
$sql="INSERT INTO PROGRAMS (program_name,owner_name,gadate,hwswboth,brandname,status,defects,design_changes)
VALUES
('$_POST[programname]','$_POST[owner]','$_POST[gadate]','$_POST[hwswboth]','$_POST[brand]','$_POST[status]','$_POST[defects]','$_POST[design_changes]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added. Select UPDATE PROGRAMS from the Menu to begin adding and managing clients";
$lastID = mysql_insert_id();
print "id = $lastID";
mysqli_close($con);
Here is my db_connection.php:
DEFINE('DATABASE_USER', 'user');
DEFINE('DATABASE_PASSWORD', 'pword');
DEFINE('DATABASE_HOST', 'hostedresource.com');
DEFINE('DATABASE_NAME', 'dbname');
// Make the connection:
$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
DATABASE_NAME);
if (!$dbc) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
[c0de]