Deprecated: mysql_connect() [duplicate] Deprecated: mysql_connect() [duplicate] php php

Deprecated: mysql_connect() [duplicate]


There are a few solutions to your problem.

The way with MySQLi would be like this:

<?php$connection = mysqli_connect('localhost', 'username', 'password', 'database');

To run database queries is also simple and nearly identical with the old way:

<?php// Old waymysql_query('CREATE TEMPORARY TABLE `table`', $connection);// New waymysqli_query($connection, 'CREATE TEMPORARY TABLE `table`');

Turn off all deprecated warnings including them from mysql_*:

<?phperror_reporting(E_ALL ^ E_DEPRECATED);

The Exact file and line location which needs to be replaced is "/System/Startup.php > line: 2 " error_reporting(E_All); replace with error_reporting(E_ALL ^ E_DEPRECATED);


You can remove the warning by adding a '@' before the mysql_connect.

@mysql_connect('localhost','root','');

but as the warning is telling you, use mysqli or PDO since the mysql extension will be removed in the future.


To suppress the deprecation message for this alone (and stay informed of other deprecations in your code) you can prefix the connect with @:

<?php$connect = @mysql_connect('localhost','root','');mysql_select_db('dbname');?>