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.
mysqli_error($conn)
way, have thrown syntax error this.
i.e.:
if(!$sql2){ echo "error: " . mysqli_error($conn); }
Comments
Post a Comment