Connection problems [closed]

-4

When sending the form to register the email entered in the field it should simply register in the database, but it does not register, how can I resolve it?

<?php    
    $conect = mysqli_connect('127.0.0.1','root@localhost','') or die ("erro de conecção");
    $banco = mysqli_select_db($conect,'oserpoeta');
    var_dump($banco)
?>

Data pickup page

<?php     
    include = 'cad_&else.php';

    //Cadastra os dados
    $email = $_POST ["email"];    
    $link = "INSERT INTO 'newllester' ('email') VALUES ('$email')";    
    $qur = mysqli_query($link,'$sql')or die('erro:'.mysqli_error ());    
    header("location: http://serpoeta.localhost/serpoeta/")    
?>
    
asked by anonymous 25.10.2017 / 20:56

1 answer

0

With mysqli you do not need to use mysqli_select_db , just use the following code

$conect = mysqli_connect('servidor','nome_utilizador','palavra_pass', 'nome_da_db') or die ("erro de conecção");


$link = "INSERT INTO 'newllester' ('email') VALUES ('$email')";

$qur = mysqli_query($link,'$sql')or die('erro:'.mysqli_error ());

In addition, the above code is poorly worded. Where you say the query, the first data must be the connection to the database, ie

$qur = mysqli_query($conect, $link)or die('erro:'.mysqli_error ());
    
25.10.2017 / 21:03