“警告:mysql_query():提供的参数不是有效的MySQL链接" - 为什么? [英] "Warning: mysql_query(): supplied argument is not a valid MySQL-Link" - Why?

查看:82
本文介绍了“警告:mysql_query():提供的参数不是有效的MySQL链接" - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有什么问题?我不断收到此错误:Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in functions.php on line 4 error reading database

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 reading database

function gameTableCheck($gn) 

{

    $result = mysql_query("SHOW TABLES LIKE '$gn'",$db) or die ('error reading database'); //This is line 4
    if (mysql_num_rows ($result)>0) {
        return true;
    } else {
        return false;
    }
}

if( gameTableCheck($page) === false ) {
        echo "MAO";
        die();
    }

推荐答案

$db不是函数gameTableCheck内部的局部变量,您需要在函数顶部添加global $db;语句.

$db is not a local variable inside function gameTableCheck, you need to add a global $db; statement at the top of the function.

这篇关于“警告:mysql_query():提供的参数不是有效的MySQL链接" - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆