Difficulty in adding PHP data MYSQL

0

Well, the title itself is already self-explanatory. Perhaps the only relevant detail I can add is the fact that when I perform the operation I do not receive any errors or warnings.

Thanks in advance for the answers.

    <?php

        if($_POST){
        ///conexao 
        $con = mysqli_connect('localhost', 'root','','SocialNetwork');

        if (mysqli_connect_errno())
        {
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }

        ///variaveis
        $name = $_POST['name'];
        $description = $_POST['description'];
        $maxguest = $_POST['maxguest'];
        $currentguest = $_POST['currentguest'];
        $address = $_POST['address'];
        $privacy = $_POST['privacy'];


        ///insercao dos elementos no banco de dados
        $query = "INSERT INTO 'events'('name', 'description', 'maxguest', 'currentguest', 'address', 'privacy') VALUES ('$name', '$description', '$maxguest', '$currentguest', '$address', '$privacy')";

        mysqli_query($con,$query or die(msqli_error($con)));
    }

?>

<h1>New event</h1>
<form class="form" action="newEvent.php" method="post" enctype="multipart/form-data" autocomplete="off"><br><br>
    <input type="text" name="name" value="" placeholder="partys name" required /><br><br>
    <input type="text" name="description" value="" placeholder="description" required /><br><br>
    <input type="number" name="maxguest" value="" placeholder="guests limit" required /><br><br>
    <input type="number" name="currentguest" value="" placeholder="current guests" required /><br><br>
    <input type="text" name="address" value="" placeholder="address" required /><br><br>
    <input type="radio" name="privacy" value=0 checked>Public<br><br>
    <input type="radio" name="privacy" value=1>Private<br><br>
    <input type="submit" name="newParty" value="new party!"/>
</form>
    
asked by anonymous 08.05.2017 / 00:33

1 answer

1

What is not letting you add data is

mysqli_query($con,$query or die(msqli_error($con)));

 <?php
 if($_POST){
    ///conexao 
    $con = mysqli_connect('localhost', 'root','SENHA','SocialNetwork');


    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    ///variaveis
    $name = $_POST['name'];
    $description = $_POST['description'];
    $maxguest = $_POST['maxguest'];
    $currentguest = $_POST['currentguest'];
    $address = $_POST['address'];
    $privacy = $_POST['privacy'];

    mysqli_query($con,"INSERT INTO 'events'('name', 'description', 'maxguest', 'currentguest', 'address', 'privacy') VALUES ('$name', '$description', '$maxguest', '$currentguest', '$address', '$privacy')") or die(mysqli_error($con));
}

?>
    
08.05.2017 / 04:07