NoDoze Posted August 14, 2008 Share Posted August 14, 2008 Between: INSERT INTO tbl_auth_user SET user_id='$user_id', user_password='$user_password' , ID = '3' and: INSERT INTO tbl_auth_user (user_id, user_password) VALUES ('user', PASSWORD('password')) I know the top one is entering info based on form results. And the bottom one is entering the info directly into mysql. But what's ID='3' ? And why when the bottom one is entered into mysql, the password is encrypted? I'm trying to replicate the bottom line entry, but instead via a php form, with the same password encryption, possible? All my attempts so far to enter an encrypted password via a php form have failed Any input helpful, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/ Share on other sites More sharing options...
NoDoze Posted August 14, 2008 Author Share Posted August 14, 2008 Would this work? $sql = "INSERT INTO tbl_auth_user (user_id, user_password) VALUES (user_id='$user_id', PASSWORD(user_password='$user_password'))"; Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616756 Share on other sites More sharing options...
revraz Posted August 14, 2008 Share Posted August 14, 2008 In your first example, the SET is really just like the VALUES, so you are setting the 3 columns with the values after the = sign. So you are setting the ID of that row to 3 in your first example. If your ID field is auto_increment, then you wouldn't need to set a ID value since the auto would take care of that for you. Now if you already had a ID of 3 somewhere, you would need to use UPDATE to change the fields data instead of INSERT. MySQL has its own Password hasher, and yes, it's called PASSWORD which you show above. But I would highly recommend you don't use that and use SHA1 instead (or even MD5). In your 2nd post, try it and see. Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616786 Share on other sites More sharing options...
adam84 Posted August 14, 2008 Share Posted August 14, 2008 Between: INSERT INTO tbl_auth_user SET user_id='$user_id', user_password='$user_password' , ID = '3' and: INSERT INTO tbl_auth_user (user_id, user_password) VALUES ('user', PASSWORD('password')) I don't think the first example would work because you use the 'SET' keyword to update a table rather then to insert something into a table. UPDATE tbl_auth_user SET user_id='$user_id', user_password='$user_password' WHERE ID = '3' You code would work, but since you dont have a WHEREclause, it is going to update every row in your tbl_auth_user table. Which isn't a good idea Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616792 Share on other sites More sharing options...
revraz Posted August 14, 2008 Share Posted August 14, 2008 You can use SET with INSERT Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616812 Share on other sites More sharing options...
NoDoze Posted August 14, 2008 Author Share Posted August 14, 2008 I'm not updating a record, I'm creating a new one.... I have yet to test it, got side tracked... Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616890 Share on other sites More sharing options...
revraz Posted August 14, 2008 Share Posted August 14, 2008 Is your ID field auto increment? Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616893 Share on other sites More sharing options...
NoDoze Posted August 14, 2008 Author Share Posted August 14, 2008 $sql = "INSERT INTO tbl_auth_user (user_id, user_password) VALUES (user_id='$user_id', PASSWORD(user_password='$user_password'))"; This is the line I plan to use...as I posted above About to test it now... Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616942 Share on other sites More sharing options...
revraz Posted August 14, 2008 Share Posted August 14, 2008 It's wrong $sql = "INSERT INTO tbl_auth_user (user_id, user_password) VALUES ('$user_id', PASSWORD ('$user_password'))"; You dont enter the field names twice. Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616943 Share on other sites More sharing options...
NoDoze Posted August 14, 2008 Author Share Posted August 14, 2008 hehe It enter a username of 0 LOL yea, I figured that...opps... I'll give that a try now... Quote Link to comment https://forums.phpfreaks.com/topic/119712-whats-the-difference/#findComment-616964 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.