Dark Sterix Dark Sterix - 6 months ago 10
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'");
mysql_set_charset('utf8');


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

Answer

Please try with example

<?php
$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";
?>