How to put mysql inside a php function?

后端 未结 6 1054
梦谈多话
梦谈多话 2021-01-14 15:37

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(

6条回答
  •  日久生厌
    2021-01-14 15:55

    Because variables are local to functions. You need to add this inside your function:

    global $connection;
    

提交回复
热议问题