I am trying to build a simple custom CMS, but I\'m getting an error:
Warning: mysqli_query() expects parameter 1 to be MySQLi, null given in
The getPosts()
function seems to be expecting $con
to be global, but you're not declaring it as such.
A lot of programmers regard bald global variables as a "code smell". The alternative at the other end of the scale is to always pass around the connection resource. Partway between the two is a singleton call that always returns the same resource handle.