Solved

php mysql encrypt

Posted on 2012-03-26
4
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 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