doubi1910 2013-10-30 16:20
浏览 67
已采纳

不推荐使用的函数mysql_db_query错误

Recently after my hosting updated its php version i've got error in my website and here is the error message

Deprecated: Function mysql_db_query() is deprecated in /my_path/file.php on line 13 
Deprecated: Function mysql_db_query() is deprecated in /my_path/file.php on line 14

Here is the code of the file.php

require_once("db.php"); // connect
$timeoutseconds = 100;
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;


mysql_db_query($db, "INSERT INTO online VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')") or die("0 Users online"); // this is line 13 that shows error

mysql_db_query($db, "DELETE FROM online WHERE timestamp<$timeout") or die("0 Users online"); // this is line 14 that shows error

Is there explain for this error and how can fix it ? ~ thanks

Note : i know about mysqli and pdo but can't shift to any since my website depends mainly on mysql and will needs months to do major changes so please can you stick with mysql.

  • 写回答

2条回答 默认 最新

  • dongyi3616 2013-10-30 16:22
    关注

    You will need to upgrade to MySQLi or even better, PDO. However, I understand that you may need a solution as of right now because you have a live website and you want to hide errors (yet the website will still work). But, you will need to consider upgrading because theses functions will be removed in a near future.

    Add this to your main file at the top.

    error_reporting(E_ALL ^ E_DEPRECATED);
    

    or

    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类