Jump to content

Recommended Posts

Using MSSQL database I am attempting to insert a new user into a table using the following command in PHP:-
INSERT INTO Users (FirstName, LastName, Usrname, Passwrd, AccessLevel, last_login, UserID)
VALUES ('Alf', 'Stockton', 'alf',0xd8cc7e40d17aaefd27cd324f7ba91079, '9', '2006/09/29 12:05:23', '0')
However this fails and I am not sure why.
BTW The value starting 0xd8....... is the password converted via md5()
Please tell me what I got wrong.
Link to comment
https://forums.phpfreaks.com/topic/22477-failing-to-insert-binarymd5-password/
Share on other sites

I am 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:-

    $passwd = "";      // for debugging only
    $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)
        {
        $Message = sprintf("%s %d <br>Record not inserted. Please refer
problem to Admin.", __FILE__, __LINE__);
        trigger_error($Message, E_USER_ERROR, $link);
        exit;
        }

Maybe on an insert, no rows would be returned and therefore I possibly
should be checking for something other than "if ($Reply == FALSE)"?

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.