Problem using md5 to insert encrypted password into table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prosad
    New Member
    • Jul 2007
    • 27

    Problem using md5 to insert encrypted password into table

    hi!

    Am having a problem inserting password after encrypting into a column of a table. am using MySQL.

    $[PHP]loginid = $_POST['loginid'];
    $password = $_POST['password'];
    $encrypt_passwo rd = md5($password);

    if ($_POST['submit']) {

    mysql_select_db ("CSU", $con);
    $sql="INSERT INTO login2 (loginid, password, privilege) VALUES ('$_POST[loginid]', $encrypt_passwo rd, '$_POST[privilege]')";
    if (!mysql_query($ sql,$con)) {die('Error: ' . mysql_error()); }

    mysql_close($co n)

    ;}[/PHP]

    table columns are loginid, password, privilege
    column for insert into is password, Not Null, VarChar(40).
    Getting the error Unknown column 'bc7hjsfsd8sse3 sder3...' in field list.
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    #2
    Your SQL looks alright for the most part, but because MD5 produces a string of numbers and letters, you might need to put quotes around it. That could be your problem.

    Hopefully that works.

    Greg

    Comment

    • prosad
      New Member
      • Jul 2007
      • 27

      #3
      Originally posted by gregerly
      Your SQL looks alright for the most part, but because MD5 produces a string of numbers and letters, you might need to put quotes around it. That could be your problem.

      Hopefully that works.

      Greg
      works fine. added quotes.
      thus used
      Code:
      '$encrypted_password'
      instead.
      thnks.

      Comment

      Working...