致命错误:调用未定义的mysql_函数

时间:2017-09-22 11:41:52

标签: php mysql sql mysqli

我需要帮助这是什么:

  

PHP致命错误:未捕获错误:调用未定义的函数   /home/volvo/public_html/config.php:8中的mysql_connect()               堆栈跟踪:               #0 /home/volvo/public_html/index.php(22):include()               #1 {main}                 在第8行的/home/volvo/public_html/config.php中引发

如何解决... 这是我的配置代码:

$dhost = "localhost"; //localhost
$dusername = "user232"; // user
$dpassword = "komplex56"; // pass
$ddatabase = "dvuhg"; // database

$con = mysql_connect($dhost, $dusername, $dpassword) or die("Cannot Connect"); 
mysql_select_db($ddatabase, $con);

if($_COOKIE["usNick"] and $_COOKIE["usPass"])
{
$q = mysql_query("SELECT * FROM tb_users WHERE username='{$_COOKIE['usNick']}' AND password='{$_COOKIE['usPass']}'") or die(mysql_error());
if(mysql_num_rows($q) == 0)
{
$_COOKIE['usNick'] = false;
$_COOKIE['usPass'] = false;
} else {
$loggedin = 1;
$r = mysql_fetch_array($q);
}
}
$da = date("j");

    $queryxx = "DELETE FROM ad_clicks WHERE day!='$da'";
mysql_query($queryxx);

$q2 = mysql_query("SELECT * FROM settings");
while($r2=mysql_fetch_array($q2))
{
$set[$r2[setname]]=$r2["setvalue"];
}
mysql_query("UPDATE settings SET setvalue='0', set_day='{$da}' WHERE set_day!='{$da}' AND set_day>'0'") or die(mysql_error());
$user=$_COOKIE['usNick'];

1 个答案:

答案 0 :(得分:3)

mysql_*已被删除,因此使用PHP 7或更高版本的任何内容都无法使用mysql_扩展名。

您可以使用mysqli_*PDO,它们都是更安全的选择。