douningle7944 2013-03-17 22:18
浏览 52
已采纳

警告:mysql_fetch_assoc():提供的参数不是有效的MySQL [重复]

I met some trouble with that error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in In fact for not having global variables I put all my query in functions.

My queries are ok, no mistakes in the fields name of where ever else.

The trouble is that on local all is fine working, when I put it online, it does not workd, and everywhere it return me some mistakes

for the home I have this mistakes:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /web/teamfrancestron/www/lib_php/strongman.php on line 75

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /web/teamfrancestron/www/lib_php/strongman.php on line 90

My user have all privilege in the database,

here is the code I use : here is for the first mistake

function fetchAccueil() {
    $sql = "SELECT 
                    `content`, `date_maj`, `id_maj`, `titre` 
            FROM `stg_man_home` 
            WHERE 
                    `id` = '1'";
    $result = mysql_query($sql);
    return mysql_fetch_assoc($result);
}

And there for the other query

/** * Fonction qui va chercher l'identité d'une personne. * @param type $id * @return type */

function fetchIdentity($id) {
    $input_id = mysql_real_escape_string($id);
    $query = "SELECT 
                        `nom`, `prenom`
              FROM `stg_man_users`
              WHERE `id` = '{$input_id}'";
    $result = mysql_query($query);
    return mysql_fetch_assoc($result);
}

I realy do not see any mistakes on names fileds, I'm sure that my queries are valid ressources. (works on local but not on the server). Im on php 5.4

On other pages I have still the same mistakes

Anykind of help will be much appreciated.

</div>
  • 写回答

3条回答 默认 最新

  • dtslobe4694 2013-03-17 22:23
    关注

    Check the return value of mysql_query. It can be a result set, but also just the value false. Change your query to

    $result = mysql_query($sql) or die(mysql_error());
    

    and you will see the problem at once.

    As a sidenote: consider switching to mysqli or PDO, because mysql_* functions are deprecated by now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端