Error connecting database (Fatal error: Uncaught Error: Call to Undefined Function mysql_connect() in )

Asked

Viewed 4,059 times

0

am having problems connecting the database of my website. The following error happens:

    Fatal error: Uncaught Error: Call to undefined function mysql_connect()                         in /home/cardgamming/www/configuracao.php:10 Stack trace: #0         /home/cardgamming/www/Painel/inicio.php(2): include() #1 {main} thrown in                 /home/cardgamming/www/configuracao.php on line 10

Follow the code below:

    <?php
    error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
    $link_fake = "http://cardgaming.net/"; // SUA URL

    $config['host']     = 'mysql04-farm62.kinghost.net'; // HOST DO BANCO DE                                                 DADOS
    $config['user']     = 'card_add1'; // LOGIN DO BANCO DE DADOS
    $config['pass']     = 'senha123'; // SENHA DO BANCO DE DADOS
    $config['db']       = 'cardgaming'; // NOME DO BANCO DE DADOS

    $selecao =         mysql_connect($config['host'],$config['user'],$config['pass'])or die("erro         dados");
    $conexao = mysql_select_db($config['db'],$selecao);

    mysql_query("SET NAMES 'mysql'");
    mysql_query('SET character_set_connection=mysql');
    mysql_query('SET character_set_client=mysql');
    mysql_query('SET character_set_results=mysql');

    $seuemail = "[email protected]"; //CONFIGURE SEU EMAIL
    $assunto_email = "cardgamming"; //ASSUNTO QUE CHEGARA O EMAIL

Since thanks!

1 answer

0

Functions of type mysql_* have been removed in PHP7. You probably have the PHP7 version.

mysql_* functions are obsolete. The recommendation is to use MYSQLI or PDO.


SOLUTIONS TO YOUR PROBLEM

Solution one (most recommended): use PDO or MYSQLI. mysqli, for example, is too similar to mysql:

$conexao = mysqli_connect('localhost', 'usuario', 'senha', 'banco_de_dados');

Solution two (less recommended): change the version of your php. Just download an earlier version.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.