In my unfamiliarity with mysqli, I fought with this one a while before figuring out that, no duh, closing the mysqli with mysqli_close($mysqli); destroys the connection and makes subsequent calls (I was logging in, closing, then trying to insert using the same mysqli link) impossible.

Solution: As scripts automatically close database connections when they complete, we don’t technically have to write the close ourselves unless we need to force it to close on long running processes that don’t need the connection to be open for it. But since I’m doing very quick pulls and inserts and no real processing, I can just let the PHP close the connection for me.

 

the connection resource is automatically destroyed after the processing on a page request ends. To SOLVE, I have to re-require connect.php (my connection to the DB) for each time I send out the req.