Solved

php mysql encrypt

Posted on 2012-03-26
4
343 Views
Last Modified: 2012-08-14
I have been having a problem with my sql in my entry form.  I can't get the encryption sha1 to work. I hope it will be obvious to someone else what I'm doing wrong here:

1)   I have been able to successfully run this sql in the SSH window by manually entering it:

INSERT INTO tblProfiles VALUES ('jessname22','jess22',0,1, sha1('jess22'));

2)   But I can't get it to work from my website using php:

$sqll = "INSERT INTO tblProfiles VALUES ('$custID','$password',0,1,sha1('$pswd'));";

3)  To see what the rendered sql looks, like I added this code:

echo ("sqll:  " . $sqll);

This is what it displayed:

sqll:INSERT INTO tblProfiles VALUES ('bartname22','bart22',0,1,sha1('bart22'));

If you see my problem, I'd appreciate a heads-up.

Thanks,

Lynn
0
Comment
Question by:Lambel
4 Comments
 
LVL 24

Expert Comment

by:johanntagle
ID: 37769599
Usually you don't need the ending semicolon when you define an SQL inside a scripting language.  Try the following:

$sqll = "INSERT INTO tblProfiles VALUES ('$custID','$password',0,1,sha1('$pswd'))";
0
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 200 total points
ID: 37770647
Are you adding error reporting to your result statement so you can see what the error is?
$result = mysql_query($sqll) or die('Query failed: ' . mysql_error());
0
 
LVL 9

Accepted Solution

by:
rinfo earned 300 total points
ID: 37770711
Why not just assign a variable to the value sha1('$pswd') and use that in the query;
$hash1 = sha1('$pswd');
$sqll = "INSERT INTO tblProfiles VALUES ('$custID','$password',0,1,'$hash1')";
0
 

Author Closing Comment

by:Lambel
ID: 37771473
Thanks very much for the comments.
@rinfo: That is a wonderful idea. I'll try it out tonight.
@nanharbison: Thanks for the comment, althought it isn't the solution, it is another good piece of advice.  I appreciate all your help.
Lynn
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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…

832 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