Jump to content

Archived

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

stockton

Failing to insert binary(md5()) password

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.

Share this post


Link to post
Share on other sites
Why don't you just use char(32)? I can't imagine that the 16 bytes you'd "lose" per row is that critical...

If you want to use a field, as the other poster said, use binary(16), or image.

Share this post


Link to post
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)"?

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.