Jump to content

Checking for result of call to mssql_query()


stockton

Recommended Posts

Am I misunderstanding the PHP Manual, where it says:-
mixed *mssql_query* ( string query [, resource link_identifier [, int batch_size]] )

Returns: A MS SQL result resource on success, *TRUE* if no rows were returned, or *FALSE* on error.

and my code reads:-

$insert = sprintf("INSERT INTO Users (FirstName, LastName, Usrname,Passwrd, AccessLevel, last_login,UserID)
                        VALUES ('%s', '%s', '%s', '%s', '%d', '%s', '%d')",
                            $FirstName, $Surname, $uname, $passwd,$accesslevel, $regdate, $_SESSION['UID']);
$Reply = mssql_query($insert, $link);
if ($Reply == FALSE)
        {
whether the query works or not I have yet to find $Reply equal to FALSE.
Please tell me what I am misunderstanding and what is the correct method  ????
Link to comment
Share on other sites

You dont have to explicitly check for true or false.

[code]$insert = sprintf("INSERT INTO Users (FirstName, LastName, Usrname,Passwrd, AccessLevel, last_login,UserID)
                        VALUES ('%s', '%s', '%s', '%s', '%d', '%s', '%d')",
                            $FirstName, $Surname, $uname, $passwd,$accesslevel, $regdate, $_SESSION['UID']);
$Reply = mssql_query($insert, $link);
if ($Reply)
{
    echo "Data Inserted";
}
else
{
  echo "Not Inserted";
}
[/code]
Link to comment
Share on other sites

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.