help with PHP transactions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gammaman
Forum Commoner
Posts: 45
Joined: Tue Feb 12, 2008 9:22 am

help with PHP transactions

Post 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";
  }
?>
 
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: help with PHP transactions

Post by yacahuma »

sorry i have not tried your code but you should try adodb smart transactions
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with PHP transactions

Post 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();
  }
(#10850)
Post Reply