简体   繁体   English

如何隐藏“Deprecated:mysql_connect()”警告?

[英]How to hide “Deprecated: mysql_connect()” warning?

I have problem.. Well.. The code that I am using is working like a dream but this message makes page look awful 我有问题..嗯..我正在使用的代码就像一个梦想,但这个消息使页面看起来很糟糕

Deprecated: mysql_connect(): The mysql extension is deprecated and

I want to hide this message from the page. 我想从页面隐藏此消息。 Is it possible and if so.. How? 有可能,如果是的话......怎么样?

It shows that message in this page: 它显示此页面中的消息:

    <?php
session_start();
include_once 'dbconnect.php';

if(isset($_SESSION['user'])!="")
{
 header("Location: panel.php");
}
if(isset($_POST['btn-login']))
{
 $email = mysql_real_escape_string($_POST['email']);
 $upass = mysql_real_escape_string($_POST['pass']);
 $res=mysql_query("SELECT * FROM users WHERE email='$email'");
 $row=mysql_fetch_array($res);
 if($row['password']==md5($upass))
 {
  $_SESSION['user'] = $row['user_id'];
  header("Location: panel.php");
 }
 else
 {
  ?>
        <script>alert('Nimimerkki/Salasana väärin, yritä uudelleen');</script>
        <?php
 }

}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
<title>Kirjaudu Adminpaneeliin</title>
<style>
/*CSS File For Sign-In webpage*/
#body-color{
background-image: url("/admin/kuvat/adminbg.gif");
}
#Sign-In{
border:3px solid #a1a1a1;
padding:9px 35px; 
background:#58FA58;
width:250px;
border-radius:20px;
box-shadow: 7px 7px 6px;
}
#button{
border-radius:10px;
width:100px;
height:40px;
background:#01DF01;
font-weight:bold;
font-size:20px
}
</style>
<!-- Koodi -->
</head>
<body id="body-color">
    <center><img src="/admin/kuvat/adminpaneeli.gif">
<div id="Sign-In">
<fieldset style="width:30%"><legend>Kirjaudu</legend>
<form method="post">
Sähköposti <br><input type="text" name="email" size="40">
<br>
Salasana <br><input type="password" name="pass" size="40">
<br>
<input id="button" type="submit" name="btn-login" value="Kirjaudu!">
</form>
</fieldset>
<br><font color="red"><i>Ongelmia kirjautumisessa?<br>Ota yhteyttä Sulivixiin!</i></font>
</div>
<br><br>
<a href="http://kamakellari.eu"><img src="/admin/kuvat/etusivulle.gif"></a>
</center>
</body>
</html>

For your own safety: Just don't use mysql_connect ! 为了您自己的安全:只是不要使用mysql_connect

Switch to mysqli or pdo . 切换到mysqli或pdo


Anyway to hide/suppress deprecated warnings you may do: 无论如何要隐藏/禁止您可能会做的弃用警告:

error_reporting(E_ALL ^ E_DEPRECATED);

or to suppress all errors/warnings: 或者压制所有错误/警告:

error_reporting(0);

You can do it by turn off reporting error type of E_DEPRECATED . 您可以通过关闭E_DEPRECATED的报告错误类型来执行此操作

error_reporting(E_ALL ^ E_DEPRECATED);

Put above line at the top of the PHP script to avoid such messages. 将上面的行放在PHP脚本的顶部以避免此类消息。

Though 虽然

mysql_*() extensions were deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. 在PHP 5.5.0中不推荐使用mysql _ *()扩展,并且它已在PHP 7.0.0中删除。 Instead, the MySQLi or PDO_MySQL extension should be used. 相反,应该使用MySQLiPDO_MySQL扩展。

Make sure you update your scripts ASAP . 确保尽快更新脚本。

对我来说,添加“@”的选项仅适用于:

@mysql_pconnect()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM