Solved

php mysql encrypt

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

707 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

19 Experts available now in Live!

Get 1:1 Help Now