Dark Sterix Dark Sterix - 1 year ago 41
SQL Question

My whole script is not working because of a deprecated mysql

This is the line that is causing problems.

mysql_connect($dbhost ,$dbuser, $dbpass); mysql_select_db($dbname);

mysql_query("SET NAMES 'utf8'");

I just got the code from codecanyon and I don't understand how to fix it. It says that it's deprecated

Answer Source

Please try with example

$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";