Solved

MD5 in oracle

Posted on 2003-10-24
5
3,623 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now