php – Using two mysqli prepare () can cause problems?-ThrowExceptions

Exception or error:

Have a nice day everyone! My question is: I use two mysqli_prepare () at once, one by one, and my question is whether this could be the case or it could cause a problem. The other thing is that when using the two in the database from which table I queried all records have disappeared (just queried, no deletion). Could this be caused by using two mysqli_prepare ()? I use two because when I register, I want to check the existence of the username and email separately in the database, and since I look separately, I will be able to display a warning message separately if one or both already exists in the database.

   $query = "SELECT usern FROM users WHERE usern = ?";
   $query2 = "SELECT email FROM users WHERE email = ?";
   $statment = mysqli_prepare($connection, $query);
   $statment2 = mysqli_prepare($connection, $query2);
   if ($statment && $statment2) {
       mysqli_stmt_bind_param($statment, "s", $_POST['felhasznalonev']); //bind-hozzákötés"s"-string
       $result = mysqli_stmt_get_result($statment);
       $record = mysqli_fetch_assoc($result);

       mysqli_stmt_bind_param($statment2, "s", $_POST['email']); //bind-hozzákötés"s"-string
       $result2 = mysqli_stmt_get_result($statment2);
       $record2 = mysqli_fetch_assoc($result2);
if($record > null)
echo "A felhasználónév már foglalt";
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *