Last active
September 11, 2018 07:42
-
-
Save wowdyaln/ae14953e15a7d31e81f8431f04676d03 to your computer and use it in GitHub Desktop.
code snippet for question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// ... ... | |
$conn->autocommit(FALSE); | |
$conn->begin_transaction(); | |
for ($i=0; $i < count($users); $i++){ | |
$user = $users[$i]; | |
$nickname = $nicknames[ mt_rand(0, count($nicknames)-1 )]; | |
$password = password_hash('123', PASSWORD_DEFAULT); | |
$createUser = "INSERT INTO `users` (`id`, `username`, `nickname`, `password`) VALUES (NULL, '{$user}', '{$nickname}', '{$password}') "; | |
if ($conn->query($createUser)) { | |
echo "good! create a user: '$user'. <br> "; | |
} else { | |
echo " Error: {$conn->error} : | |
sql: {$createUser} "; | |
} | |
} | |
$conn->commit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment