Database connection error

5

I have a problem connecting to MySQL database with PHP I am using WAMP I created a database in my PHPMyAdmin I made my connection via PHP but this error appears when I click send in my form :

Thesearethecodesformyconnection:

config.php

<?php$db['server']='localhost';$db['user']='felipe';$db['password']='lalala';$db['dbname']='base_teste';//estabeleceumaconexaocomserverdebd('servidor','usuario','senha')$conn=mysql_connect($db['server'],$db['user'],$db['password']);//conexaocombancomysql_select_db($db['dbname'],$conn);?>

funcoes.php

<?phpfunctionadicionar($nome,$idade){$sql="insert into tb_alunos (nome,idade) values ('$nome','$idade')";
        mysql_query($sql);
    }
?>

add.php

<?php
    include 'config.php';
    include 'funcoes.php';

    adicionar ($_REQUEST['nome'],$_REQUEST['idade']);
?>

index.php

<!DOCTYPE html>
<html>
<head>
    <title>conexao teste</title>
</head>
<body>
    <form action="adiciona.php" method="post">
        nome <input type="text" name="nome">
        Idade <input type="text" name="idade">
        <input type="submit" value="Enviar">
    </form>
</body>
    
asked by anonymous 16.07.2015 / 18:44

2 answers

5

It is telling you not to use these functions based on the old extension that gives access to MySQL. You should switch to MySQLi ". You can also switch to PDO, but I do not advise.

Have information here . See a example of how to swap .

    
16.07.2015 / 18:48
2

Use Msqli

Documentation:

link

    
16.07.2015 / 18:47