stockton Posted September 7, 2007 Share Posted September 7, 2007 The documentation says & I quote Returns a MS SQL result resource on success, TRUE if no rows were returned, or FALSE on error. and I really do not understand what I should do to ensure that the SQL INSERT was successful. My code looks like:- $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $BonusValue-$BonusIssued, 0, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if ($rs===FALSE) Will $rs be TRUE, FALSE or something else on successful completion? Quote Link to comment https://forums.phpfreaks.com/topic/68370-solved-understanding-documentation-on-mssql_query/ Share on other sites More sharing options...
lemmin Posted September 7, 2007 Share Posted September 7, 2007 Your code will work. If you do a boolean comparison on the variable and it has the successful resource in it, it should return true too. A common method is using or after the statement, which will execute if the function returns false. $rs = mssql_query($SQL, $link) or die ("error message: " . mssql_get_last_message()); Quote Link to comment https://forums.phpfreaks.com/topic/68370-solved-understanding-documentation-on-mssql_query/#findComment-343763 Share on other sites More sharing options...
stockton Posted September 8, 2007 Author Share Posted September 8, 2007 Thank you for your reply. What I really need to do is keep two tables in the same database in step by using two SQL INSERT statements and check after each that the INSERT commands succeeded and if not back out the database. Quote Link to comment https://forums.phpfreaks.com/topic/68370-solved-understanding-documentation-on-mssql_query/#findComment-344180 Share on other sites More sharing options...
stockton Posted September 10, 2007 Author Share Posted September 10, 2007 Sorry that was a silly question and I should know better. This is not a PHP problem but rather a SQL issue. START TRANSACTION and COMMIT should be all I need. Quote Link to comment https://forums.phpfreaks.com/topic/68370-solved-understanding-documentation-on-mssql_query/#findComment-345219 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.