Jump to content


Photo

Failing to insert binary(md5()) password


  • Please log in to reply
3 replies to this topic

#1 stockton

stockton
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts
  • LocationMidrand South Africa

Posted 29 September 2006 - 10:50 AM

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.
Regards,
Alf Stockton   Programmer for rent.

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 30 September 2006 - 04:50 PM

What is the field type of "Passwrd" ? try using "binary" type if you havent.
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 MCP

MCP
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 01 October 2006 - 10:32 PM

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.

#4 straygrey

straygrey
  • Members
  • PipPipPip
  • Advanced Member
  • 37 posts
  • LocationGauteng, South Africa

Posted 03 October 2006 - 12:02 PM

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


---

Regards,

Alf Stockton





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users