Database does not accept single quotes' when sending [duplicate]

0

I'm having a little problem where if on the form I type only a quotation mark 'it does not add to the database. Could someone tell me why and how could I fix this?

  

OBS¹: just with a quotation mark, if I close it with another quotation mark or place   other type of symbol sends.

     

NOTE: no type of error appears, it performs the procedure of   but does not insert into the database.

<?php
require_once("../config.php");
$nome = $_POST['nome'];
$tipo = $_POST['tipo'];
$data = $_POST['data'];

    /*Inserar na tabela */
    $query_evento = "INSERT INTO evento (nome, tipo, data) VALUES ('".$nome."', '".$tipo."', '".$data."')";
    $inserir_evento = mysql_query($query_evento);


?>
    
asked by anonymous 14.05.2018 / 19:07

1 answer

-1

You can use the addslashes function to work around this problem:

<?php
    require_once("../config.php");
    $nome = $_POST['nome'];
    $tipo = $_POST['tipo'];
    $data = $_POST['data'];

    /*Inserar na tabela */
    $query_evento = "INSERT INTO evento (nome, tipo, data) VALUES ('".addslashes($nome)."', '".$tipo."', '".$data."')";
    $inserir_evento = mysql_query($query_evento);


?>
    
14.05.2018 / 19:21