Skip navigation links

MySQL Forums :: PHP :: Multiple duplicate or blank records on a single insert!!?


Advanced Search

Multiple duplicate or blank records on a single insert!!?
Posted by: Dom Busher ()
Date: June 20, 2013 11:37AM

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]

Options: ReplyQuote


Subject Written By Posted
Multiple duplicate or blank records on a single insert!!? Dom Busher 06/20/2013 11:37AM
Re: Multiple duplicate or blank records on a single insert!!? Peter Brawley 06/20/2013 11:50AM
Re: Multiple duplicate or blank records on a single insert!!? Dom Busher 06/20/2013 12:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.