[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php mysql encrypt

Posted on 2012-03-26
4
Medium Priority
?
371 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 800 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 1200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 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