Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

php/mysql bulk convert (1) date and (2) md5 passwords

Status
Not open for further replies.
Joined
Jan 19, 2007
Posts
2,207
Reaction score
47
I've searched and think I'm getting closer but can't find answers which work.

I have two problems to solve. Can anyone help?

(1) I'm trying to convert a bunch of dates in a mysql db from varchar(20) eg. stored as "Aug 28, 2006" into int(10) format e.g. "1156741200" but can't figure out the sql query to run.

(2) I have a table with user info in it. Passwords are stored there encrypted md5. I need to change everyone's password. I could generate a list of plain text random passwords and put them in a column next to the user id's. I'm not sure of how to get the md5 version of the random password that I give them. Also I'm guessing the sql query would be:

Code:
UPDATE table_name SET password=md5value WHERE user_id=some_value

Any help really appreciated... my headache is now full blown! :confused:
 
I fixed my second problem by mail merging some data and then copying and pasting 20,000 lines like:
Code:
UPDATE members SET password = sha1("newrawpassword") WHERE id_member = "some_number";

But still not sur about #1, the date issue :(
 
Apologies if this isn't quite what you're after, but regarding the time issue have you looked at the strtotime() function in php?

strtotime("Aug 28, 2006"); outputs 1156716000. Is this what you're after? If so you could loop through the rows and replace.
 
Last edited:
EDIT: Nothing to see here
 
Last edited:
Thanks Suggys - I'll take a look.

@Alex It's a bit tricky because the date is saved with format varchar(20) and in the format "mmm dd, yyyy" eg. Aug 28, 2006.

not sure if that would still work but I can give it a try:
strtotime("Aug 28, 2006") would output 1128290400.

Thanks for reply.

Edit Missed your other reply Alex, I think that it should output "1128290400" but will give it a try. Thanks again.
 
Last edited:
I'm trying to compare the two databases and it shows that

Aug 28, 2006 = 1156741200

So I was wrong with my other number and this is very close to the number you got (1156716000)


Edit I just thought that maybe one of the DBs is also looking at time of day and this could give the discrepancy. For my purpose I don't care about time, so your method will work great.

Thanks for the help. I will try it when I wake up (gotta sleep it's 5am and I've been up all night!)
 
Edit I just thought that maybe one of the DBs is also looking at time of day and this could give the discrepancy. For my purpose I don't care about time, so your method will work great.

Thanks for the help. I will try it when I wake up (gotta sleep it's 5am and I've been up all night!)

I was wondering if that was causing it. Hopefully it will work, but give me a shout if it doesn't and I'll be happy to ponder it over with you. Until then hope you catch up on sleep!
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

Latest Comments

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom