Pvtrixx Pvtrixx - 5 months ago 12
SQL Question

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>

Answer

For your own safety: Just don't use mysql_connect!

Switch to mysqli or 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);