Solved

Sql insert into question

Posted on 2016-08-28
6
42 Views
Last Modified: 2016-08-29
Dear experts

I'd like to insert into my table unique user key
Every row has data but my uuk coloumn is empty

I have 4 coloumns on my table
_key, uid, pwd, uuk

My uuk coloumn is emty and i need unique user key for every user for cookie

How can i insert below formula to my database for each user?
I use php and mysql database

My table name is KullaniciBilgileri

// MAKE THE UNIQUE USER KEY
        $uuk = md5($uid . $pwd . rand());
0
Comment
Question by:Braveheartli
[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
6 Comments
 
LVL 1

Author Comment

by:Braveheartli
ID: 41773753
I used this article for my page which is really good

PHP Client Registration, Login, Logout and Easy Access Control

Written by:Ray Paseur
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 41773756
I have direct access to mysql database, can i do it with sql script or do i have to use php to do this?
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 41773796
I'd use php:
$uuk = md5($uid . $pwd . rand());
$query = "INSERT INTO KullaniciBilgileri (_key, uid, pwd, uuk) VALUES ('$key', '$uid', '$pwd', '$uuk')";

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41773803
Here is how I would do it...

FIrst, modify the existing code so that any new registrations automatically build the "uuk" value and store it in the database.  That will keep you from having a "regression" later.

Next, write a short and simple PHP script to do the following...

1. SELECT _key, uid, pwd FROM your database table WHERE uuk = '' /* This is an empty string */
2. Iterate over the results set.   With each row:
3. $uuk = md5($uid . $pwd . rand());
4. UPDATE your database table SET uuk = '$uuk' WHERE _key = $_key LIMIT 1

This will take on a second or two to run, and you'll only need to run it once.  Then you can use the "uuk" values as described in the article.
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41773832
Thank you
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41774489
Why not use UUID() for your unique key?
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 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