Jump to content

Archived

This topic is now archived and is closed to further replies.

stockton

Checking for result of call to mssql_query()

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  ????

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.