ID: 11427
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Bogus
Bug Type: MySQL related
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

submitted twice


Previous Comments:
---------------------------------------------------------------------------

[2001-06-12 06:27:55] [EMAIL PROTECTED]
The script was fine for an Access database but when I changed it over for a MySQL 
database the insertion queries sometimes (most of the time but not all the time) adds 
two records to the database.

Heres my connection:

$db_hostname   = "jd";
$db_username   = "john";
$db_password   = "nirvana";
$db_database   = "neuquote";

$conn = mysql_connect($db_hostname, $db_username, $db_password)
  or die ('Unable to connect to database');
                
$db = mysql_select_db($db_database,$conn)
  or die ('Unable to connect to database');

Heres my queries:

$today = getdate();
$today = $today['mday']."/".$today['mon']."/".$today['year']." 
".$today['hours'].":".$today['minutes'].":".$today['seconds'];
                                                
// Insert new company
$sql="INSERT INTO Company 
(CompanyName,CompanyAddress1,CompanyAddress2,CompanyAddress3,CompanyAddress4,CompanyArea,CompanyCountryId,CompanyPostalCode,CompanyTel,CompanyFax,CompanyEmail,CompanyURL,CompanyDesc,CompanyStatus,TimeCompanyCreated)
 ". 
                                 "VALUES 
('$company_name','$company_address1','$company_address2','$company_address3','$company_address4','$company_area',$company_country,'$company_postal_code','$company_tel','$company_fax','$company_email','$company_url','$company_desc',0,'$today')";


$res_insert_company = mysql_query($sql,$conn);

//create a new hash to insert into the db and the confirmation email
$hash=md5($email.$hidden_hash_var);
$sql="INSERT INTO CompanyContact 
(ContactTitle,ContactFirstName,ContactSurname,ContactMiddleInitial,ContactAddress1,ContactAddress2,ContactAddress3,ContactAddress4,ContactArea,ContactCountryId,ContactPostalCode,ContactTel,ContactExt,ContactFax,ContactEmail,ContactPositionId,ContactUsername,ContactPassword,ContactRemoteAddress,ContactConfirmHash,ContactStatus,TimeContactCreated,CompanyId)
 ". 
                                        "VALUES 
($title,'$first_name','$surname','$middle_initial','$address1','$address2','$address3','$address4','$area',$country_code,'$postal_code','$tel','$ext','$fax','$email',$pos,'$user_name','".
 md5($password1) ."','$GLOBALS[REMOTE_ADDR]','$hash',0,'$today',$company_id)";

$res_insert_contact=mysql_query($sql,$conn);

Most of the time two companies are added to the db and sometimes two companycontacts, 
this is not consistent though as sometimes it works fine.

I have checked the submit button is not being clicked twice and the code is running 
one insert for company and one for companycontact.

Is this a common problem with MySQL and PHP?

---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=11427&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to