0
I’m working on an old system, in which makes the connection to the bank still with mysql_query
.
I used very little mysql_query
and the last time I used it a long time ago, I’m more used to PDO
.
I’m trying to give a insert
in the bank, but the function mysql_query
is returning false
and I cannot identify the error. I have already looked at the documentation relating to mysql_query
and saw nothing wrong in my code. Someone could help me?
Follows 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 in the BD the field dataPostagem
of DATE
for VARCHAR
thinking this was it but it didn’t solve.
-_-' That’s right @Wendel Rodrigues. Thank you very much, I didn’t know that I should have the single quotes in the variables.
– Gabriel
To
string
should always use quotes in SQL. ;)– Wendel Rodrigues