How to put mysql inside a php function?

后端 未结 6 1017
梦谈多话
梦谈多话 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 16:03

    Simply put, functions ignore outside variables due to variable scope. You must let the declare the variable as being from the outside by using global or you can send $connection through a parameter.

提交回复
热议问题