Problem with insert using mysql_query ()

1

I'm working on an old system, where it makes the connection to the bank still with mysql_query .

I've used too little mysql_query and the last time I used it, it's got a lot of time, I'm more accustomed to PDO .

I am trying to give a insert in the database, but the mysql_query function is returning false and I can not identify the error. I already looked at the documentation for mysql_query and saw nothing wrong with my code. Could someone help me?

Follow the code:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $nomeVideo    = $_POST['nomeVideo'];
  $urlVideo     = $_POST['urlVideo'];
  $dataPostagem = date('d/m/Y');

  $sql = "INSERT into video (nomeVideo, urlVideo, dataPostagem)
          VALUES($nomeVideo, $urlVideo, $dataPostagem)";

  $insert = mysql_query($sql);
  var_dump($insert); exit;

  if ($insert) {
    header('Location: video.php');
  } else {
    header('Location: video.php?return=2');
  }
}

I even changed the field dataPostagem from DATE to VARCHAR thinking it was that but did not solve it.

    
asked by anonymous 24.05.2017 / 15:05

1 answer

3

I think the quotation marks in the string and date are missing:

$sql = "INSERT into video (nomeVideo, urlVideo, dataPostagem)
        VALUES('$nomeVideo', '$urlVideo', '$dataPostagem')";
    
24.05.2017 / 15:10