I am unable to run this command line due to an error in php but n know which one!

Asked

Viewed 40 times

-1

Error that appears: Fatal error: Uncaught Error: Function name must be a string in C: xampp htdocs developed rs_alpinismo salva_mensagem.php:5 Stack trace: #0 {main} thrown in C: xampp htdocs developed rs_alpinismo salva_mensagem.php on line 5

Code I did to send the data to mysql(phpmyadmin) local server:

first code: php connection.:

<?php 
    $servidor = "localhost";
    $usuario = "root";
    $senha = "";
    $dbname = "areadecontatos";

    // Criar a conexão
    $conn = mysqli_connect($servidor, $usuario, $senha, $dbname);


?>

Second code salva_mensagem.php:

<?php 

    include_once('conexao.php');

    $name = $_POST('nome');
    $email = $_POST('email');
    $menssagem = $_POST('menssagem');

   $msg_contato = "INSERT INTO mensages_contato(nome, email, menssage) VALUES ('$nome', '$email', '$email', NOW())";
   $resultado_msg_contato = mysqli_query($conn, $resultado_msg_contato)
    
?>

Html code action:

I am willing to send to the local database, the following data

Name Email Message

identification on the form of each:

name="nome"
name="email"
name="menssagem"

If anyone can help!!!!

2 answers

0

It is also necessary to correct the last variable to $menssagem, in your code is $email twice

$msg_contato = "INSERT INTO mensages_contato(nome, email, menssage) VALUES ('$name', '$email', '$menssagem', NOW())";

0

In this line of the file salva_mensagem.php:

$msg_contact = "INSERT INTO messages_contact(name, email, message) VALUES ('$name', '$email', '$email', NOW())";

The correct one has to be the passage of variables in SQL, you put $name instead of $name:

$msg_contact = "INSERT INTO messages_contact(name, email, message) VALUES ('$name', '$email', '$email', NOW())";

This line is 5, just you interpret the error message (the line 5 of the file corresponds to: $name = $_POST('name');).

Browser other questions tagged

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