Solved

MD5 in oracle

Posted on 2003-10-24
5
3,680 Views
Last Modified: 2013-12-12
hi
a very small question that , i am getting error if i write like this, i want to create login/logout for my web interface using PHP, i am using oracle

insert into users(user_id, username, password) values(1,'test', md5('test'));

can any one tell be how should i write .
As i know The md5() function is built into PHP, and will convert your password into a 32 character string. This is one good method for encrypting password information
 
desc users

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 USER_ID                                   NOT NULL NUMBER(10)
 USERNAME                                  NOT NULL VARCHAR2(20)
 PASSWORD                                  NOT NULL VARCHAR2(32)

thx
0
Comment
Question by:manish14
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:ThG
ID: 9619071

i don't have oracle here to test but it should work. First, report the error you are getting, second try:
select md5('test');

if that shouldn't work, you can still insert "values (1,'test','" . md5("test") . "');
0
 

Author Comment

by:manish14
ID: 9625841
error is ORA-00904: "MD5": invalid identifier

i tried your solution, i am getting password field like this, is it correct way to encrypt the password

 select * from users;

   USER_ID USERNAME             PASSWORD
---------- -------------------- --------------------------------
         1 test                 " . md5("test") . "
0
 
LVL 14

Expert Comment

by:ThG
ID: 9626950
what's that?! you inserted the raw string!
you need proper escaping.. please note that my md5() was a PHP function, not an ORACLE function like yours (that actually doesn't exist..)

Please keep quotes consistent:

$query = "insert into users(user_id, username, password) values(1,'test', " . md5("test") . ");";
0
 
LVL 14

Accepted Solution

by:
ThG earned 20 total points
ID: 9626955
whops.. this is the correct one:

$query = "insert into users(user_id, username, password) values(1,'test', '" . md5("test") . "');";
0
 

Author Comment

by:manish14
ID: 9641704
md5  didn't work in insert statement for me so i put md5 in the begning , like this i am inserting already encrypted value.

thx for your comment
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question