Solved

php mysql encrypt

Posted on 2012-03-26
4
346 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
The viewer will learn how to count occurrences of each item in an array.
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.

685 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