php - Im trying to generate a unique hash for all the users -


i'm trying generate unique hash users in database; here code:

<?php include("php/connect.php");   $sql = "select id user";   while ($id = mysqli_fetch_assoc(mysqli_query($conn, $sql))) {      $new_hash = md5(uniqid(rand(), true));      $sql2 = "insert user (hash) value ('$new_hash') id = $id['id']";     mysqli_query($conn, $sql2);   }  ?> 

every time run it, following error:

fatal error: maximum execution time of 30 seconds exceeded in 

regarding query:

$sql2 = "insert user (hash) value ('$new_hash') id = $id['id']"; 

insert doesn't use where clause, update does, insert ... on duplicate key update.

however, don't know why you're wanting that. using column set auto_increment should ample have unique id.

yet, if want do, need use 1 of methods shown above.

i.e.:

if(!$sql2){     echo "error: " . mysqli_error($conn);  } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -