I am getting this warning, but the program still runs correctly.
The MySQL code is showing me a message in PHP:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\xampp\htdocs\task\media\new\connect.inc.php on line 2
My connect.inc.php
page is
<?php
$connect = mysql_connect('localhost','root','');
mysql_select_db('dbname');
?>
What does this mean and how can I eliminate the message?
Warning "deprecated" in general means that you are trying to use function that is outdated. It doeasnt mean thaqt your code wont work, but you should consider refactoring.
In your case functons mysql_ are deprecated. If you want to know more about that here is good explanation already : Why shouldn't I use mysql_* functions in PHP?
Deprecated features in PHP 5.5.x
The original MySQL extension is now deprecated, and will generate
E_DEPRECATED
errors when connecting to a database. Instead, use the **MYSQLi or PDO_MySQL extensions.**Syntax:
Also, replace all
mysql_*
functions intomysqli_*
functionsinstead of
Adding a
@
works for me!I tested with
error_reporting(E_ALL ^ E_DEPRECATED);