Jump to content

[SOLVED] Understanding documentation on mssql_query


Recommended Posts

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?

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());

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.