Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Php Transaction 2011
#1
Code:
$rollbackStatus=False; $link = mysql_connect(dbHost, dbUser, dbPassword); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(dbDatabase); if(!$db) { die("Unable to select database"); } mysqli_autocommit($link, FALSE); $selectQuery1 ="Select clientName From tblClient Where clientName='".$clientName."'"; $result1 = mysql_query($selectQuery1); if ($result1 !== TRUE) { mysqli_rollback($link); $rollbackStatus=True; } $row1 = mysql_fetch_array($result1, MYSQL_ASSOC); $n1 = mysql_num_rows($result1); if($n1>0) { $status="<span class=\"statusFailed\">: Client ".$clientName." Alread Exist.</span>"; } else { $insertQuery1 = "Insert Into tblClient Set ". "clientName='".$clientName."', ". "clientContactPerson='".$clientContactPerson."',". "clientAddress='".$clientAddress."',". "clientContactNumber='".$clientContactNumber."',". "clientStatus='a'"; $result2 = mysql_query($insertQuery1,$link); if ($result2 !== TRUE) { $status="<span class=\"statusFailed\">: Error adding adding Client:" . mysql_error() . "</span>"; mysqli_rollback($link); $rollbackStatus=True; } else { $status="<span class=\"statusOk\">: Client ".$clientName." Added Succesfully.</span>"; } } if($rollbackStatus=="False") { mysqli_commit($link); } mysqli_close($link); }

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variables in function names in php 2011 Vuhelper 1 1,761 08-02-2014, 10:04 AM
Last Post: sadanturk
  PHP Login page and MySql 2011 Vuhelper 1 2,999 08-02-2014, 09:50 AM
Last Post: sadanturk
  Zip code locator issues in php 2011 Vuhelper 2 2,147 08-02-2014, 09:49 AM
Last Post: sadanturk
  checkbox and mysql in php 2011 Vuhelper 0 1,724 09-18-2011, 07:16 PM
Last Post: Vuhelper
  how can Animate your images in PHP 2011-12 Vuhelper 0 2,744 09-12-2011, 10:26 PM
Last Post: Vuhelper
  Radio button selection problem in php 2011-12 Vuhelper 0 1,661 08-27-2011, 09:05 PM
Last Post: Vuhelper
  Moving to preg_replace() from eregi_replace() in php 2011 Vuhelper 0 1,527 07-23-2011, 05:51 PM
Last Post: Vuhelper
  Upload Variables not getting passed in php 2011 Vuhelper 0 1,626 07-23-2011, 05:50 PM
Last Post: Vuhelper
  PHP include instead of iFrame 2011 Vuhelper 0 1,761 07-22-2011, 08:44 PM
Last Post: Vuhelper
  SESSION() and goto support in php 2011 Vuhelper 0 2,155 07-22-2011, 08:42 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)