“Warning: mysql_query(): supplied argument is not a valid MySQL-Link” - Why?

前端 未结 7 1195
有刺的猬
有刺的猬 2021-01-26 04:17

What\'s wrong with my code? I keep getting this error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in functions.php on line 4 error readin

7条回答
  •  暖寄归人
    2021-01-26 04:56

    Well I'd say that $db is not initialized correctly. What you want to do is to use mysql_select_db as such :

    
    

    (snippet via)

    If you do need to have a specified database variable on each query for some reason, try looking if :

    • the $db variable is set properly

    • the $db variable is within the scope of your function. Consider making it global if needed or passing it to the function as an argument

提交回复
热议问题