I have problem about putting mysql into a function showMsg(). The mysql is working fine if it is not wrapped by function showMsg(), but when I wrap it with function showMsg(
$connection
variable has no value assigned. The following code should solve your problem (add it at the beginning of the function):
global $connection;
But you should be aware of the fact, that using globals is not a good idea and you may want to:
$connection
variable within the parameter of the function, or$connection
declaration from outside the function just into the function (if it does not cause additional problems), or$connection
variable within the function (again: if it will not cause additional problems),