Page 1 of 1

help with PHP transactions

Posted: Tue May 13, 2008 6:32 pm
by gammaman
My table is not updating why?

Here is the create table stuff

mysql> create table Bank(
-> accID int not null,
-> balance float (10,2) not null,
-> Primary Key (accID));
Query OK, 0 rows affected (0.06 sec)

mysql> Insert into Bank (accID,balance) values (6,1000.00);
Query OK, 1 row affected (0.01 sec)

mysql> Alter table Bank ENGINE=innoDB;
Query OK, 1 row affected (0.06 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> Set autocommit=0;
Query OK, 0 rows affected (0.00 sec)

Here is the code:

Code: Select all

 
<?php
  mysql_connect("localhost","fierm","13183");
  mysql_select_db(fierm);
 
  mysql_query("BEGIN");
 
  $result = mysql_query("Update Bank set balance='5000.00' where accID='6'");
 
  echo "here";
 
  if($result){
  mysql_query("COMMIT");
  }
  else{
   echo "failed";
  }
?>
 

Re: help with PHP transactions

Posted: Tue May 13, 2008 6:48 pm
by yacahuma
sorry i have not tried your code but you should try adodb smart transactions

Re: help with PHP transactions

Posted: Tue May 13, 2008 6:50 pm
by Christopher
You code should be able to tell you why:

Code: Select all

 if(! mysql_error()) {
   mysql_query("COMMIT");
  } else {
   echo "Error: " . mysql_errmsg();
  }