zgkhoo Posted December 29, 2007 Share Posted December 29, 2007 mysql_query("COMMIT"); echo "</br>successful added"; tested with abnormal termination ..and found sometime ...the system already commit but doesnt display the successful msg....(maybe my abnormal termination taken after commit and before display successful msg. how to make commit and success msg ....appear together? and another question..does rollback keyword needed..since...no commit...and the system wont save the last transaction.. Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/ Share on other sites More sharing options...
nuxy Posted December 29, 2007 Share Posted December 29, 2007 The mysql_query() functin returns false if the query is not executed, or there occured an error. Use an if statement. <?php if (false == ($var = @mysql_query("COMMIT"))) { // error.. echo 'There was an error: ' . mysql_error() . '.'; } else { //success echo 'Success: ' . $var . '.'; } Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425221 Share on other sites More sharing options...
zgkhoo Posted December 29, 2007 Author Share Posted December 29, 2007 <?php mysql_query("COMMIT"); <------abnormal terminate at here.... if (false == ($var = @mysql_query("COMMIT"))) { // error.. echo 'There was an error: ' . mysql_error() . '.'; } else { //success echo 'Success: ' . $var . '.'; } wat if abnormal terminate at the point show above? will it still running the following line which showing success or failure msg? since the program already terminated(stopped at the point) at the point Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425258 Share on other sites More sharing options...
nuxy Posted December 29, 2007 Share Posted December 29, 2007 Yes, the function will run first. Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425260 Share on other sites More sharing options...
zgkhoo Posted December 29, 2007 Author Share Posted December 29, 2007 wat run first meant? still will display the msg even terminated in the middle ? Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425265 Share on other sites More sharing options...
zgkhoo Posted December 29, 2007 Author Share Posted December 29, 2007 cant ...i tried...when i click the "stop" when the system running......to terminate the system.. after it stopped....wont show "error" msg. Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425266 Share on other sites More sharing options...
zgkhoo Posted December 29, 2007 Author Share Posted December 29, 2007 <?php include '../../../config.php'; include '../../../opendb.php'; include '../adminmain.php'; include '../../../pyramidfunction2.php'; mysql_query("BEGIN"); //insert admin card module!!!!!!!!!!!!! if(isset($_POST['insertadmincard'])){ //store admin card into gamecard table $result=mysql_query("SELECT * from rate ORDER BY RID"); //while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $lastcardserial=findcurrentserial(); for($i=0,$count=$_POST['admincardnum'];$i<$count;$i++) { $lastcardserial+=1; $ID="Admin".($lastcardserial-1000); $sql="INSERT INTO gamecard(Serialnum,Serial,Ownerid) VALUES ('$ID','$lastcardserial','AdminCard')"; mysql_query($sql); mysql_query("UPDATE gamecard SET LatestSerial='$lastcardserial'") or die(mysql_error()); //$pyrtable=findpyramid($ID); $prytable=$_POST['assotable']; echo "</br>prytable=".$_POST['assotable']; addpyramidcard($ID,$_POST['assotable']); setpyramidbonus($ID,$_POST['assotable']); } } function findcurrentserial(){ $result=mysql_query("SELECT Serial from gamecard ORDER BY Serial DESC LIMIT 1 LOCK IN SHARE MODE"); if(mysql_num_rows($result)==0){ return 1001; } while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $serial=$row[serial]; } return $serial; } mysql_query("COMMIT"); //echo "</br>successful added"; if (false == ($var = @mysql_query("COMMIT"))) { // error.. echo 'There was an error: ' . mysql_error() . '.'; } else { //success echo 'Success: ' . $var . '.'; } include '../../../closedb.php'; ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <form name='insertadmincard' action='admincard.php' method=post> <table border="3"> <tr> <td>Number of Admin card to be insert into pyramid公司卡数目</td> <td><input type="text" name=admincardnum></td> </tr> <tr> <td>Select which pyramid table to be insert选择输入的金字塔</td> <td><select name=assotable> <?php include '../../../config.php'; include '../../../opendb.php'; $result2 = mysql_query("SELECT * FROM pyramidT") or die('Query failed: ' . mysql_error()); while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC)){ if($row[AssoTable]==$row2[TableName]){ echo "<option value=$row2[TableName] selected='selected'>$row2[TableName]</option>"; }//end if else{ echo "<option value=$row2[TableName]>$row2[TableName]</option>"; }//end else }//end while include '.../../../closedb.php'; ?> </select> </td> </tr> <tr> <td><input type="submit" name='insertadmincard' value='insert'><td> </tr> </table> </form> </html> Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425267 Share on other sites More sharing options...
zgkhoo Posted December 30, 2007 Author Share Posted December 30, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425753 Share on other sites More sharing options...
zgkhoo Posted December 30, 2007 Author Share Posted December 30, 2007 i didnt saw the success msg...but the data also save into db..weird. :-\ :-\ Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-425841 Share on other sites More sharing options...
zgkhoo Posted December 30, 2007 Author Share Posted December 30, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426191 Share on other sites More sharing options...
zgkhoo Posted December 31, 2007 Author Share Posted December 31, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426437 Share on other sites More sharing options...
mmarif4u Posted December 31, 2007 Share Posted December 31, 2007 mysql_query("COMMIT"); //echo "</br>successful added"; if (false == ($var = @mysql_query("COMMIT"))) { // error.. echo 'There was an error: ' . mysql_error() . '.'; } else { //success echo 'Success: ' . $var . '.'; } I am wondering why you use mysql_query("COMMIT"); even it is already in condition. So remove it and condition will check whether true or false. Try nuxy code without that like: //mysql_query("COMMIT"); //echo "</br>successful added"; if (false == ($var = @mysql_query("COMMIT"))) { // error.. echo 'There was an error: ' . mysql_error() . '.'; } else { //success echo 'Success: ' . $var . '.'; } Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426446 Share on other sites More sharing options...
zgkhoo Posted December 31, 2007 Author Share Posted December 31, 2007 wat is the @ meant? if (false == ($var = @mysql_query("COMMIT"))) { it not just only checking the condition ..but also running the query too????? Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426470 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 "@" will supress errors message... Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426473 Share on other sites More sharing options...
zgkhoo Posted December 31, 2007 Author Share Posted December 31, 2007 wat i want is...when user abnormal terminate..then it still will display the error msg(althought it already terminated) and now also when the system is display the success msg but seem not at the same time with the commit action.. (is it cause by slow speed of my computer)? the query is performing faster than the display in the page.....which sometime already commit..but havent display it on the page yet. Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426481 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 can you define what you mean by terminated ? Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426482 Share on other sites More sharing options...
zgkhoo Posted December 31, 2007 Author Share Posted December 31, 2007 press the browser's "stop" button when it running.. Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426546 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 well since HTTP is a stateless protocol it terminates when the button is pressed the only way you could do it is through AJAX and I do not think that would work too if the stop button is pressed! Quote Link to comment https://forums.phpfreaks.com/topic/83578-how-to-display-successful-msg-together-with-commit-action/#findComment-426551 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.