I've been having weird problems lately, my code is playing up badly, working one second and then not working!!
I have this query
$stuff_get = mysqli_query($con,"SELECT users.id, users.email, users.hash, users.username FROM users WHERE users.username = '$username' AND users.id=$id4");
$gotstuff = mysqli_fetch_array($stuff_get, MYSQL_ASSOC);
Which provides this error message
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
Usually that means it just generally doesn't work but it worked literally 2 minutes beforehand (without any changes).
Here's the full code
<?php
session_start();
$username = $_SESSION['userlogin'];
include("connect.php");
$id_get = mysqli_query($con,"SELECT units.id, users.id, users.username FROM units, users WHERE users.username = '$username' AND units.id = users.id");
$gotid = mysqli_fetch_array($id_get);
$id4 = $gotid["id"];
$stuff_get = mysqli_query($con,"SELECT users.id, users.email, users.hash, users.username FROM users WHERE users.username = '$username' AND users.id=$id4");
$gotstuff = mysqli_fetch_array($stuff_get, MYSQL_ASSOC);
$hash2 = $gotstuff['hash'];
$email2 = $gotstuff['email'];
$username2 = $gotstuff['username'];
echo "Your username is ",$username2,"<br>";
echo "Your activation code is ",$hash2,"<br>";
?>
It is supposed to be some of the contents of an email I send upon registration, it worked the first time I tested registration but I've since tested 5 more in the same conditions to no luck!
EDIT
IT IS NOW WORKING
I have no idea how, I didn't change a thing. I think it was to do with the sessions.