I have some problems when I upload a picture, it uploads to the directory but in SQL it doesn't put the name, only puts 1 or 0
https://i.sstatic.net/KxSaO.jpg
In SQL, it's all in varchar(255).
if(isset($_POST["submit"])) {
$date=date("d/m/Y");
$target_dir = "../img/logo/";
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'],$target_dir.$_FILES['fileToUpload']['name'])){
$insert=mysqli_query($db, "UPDATE logo SET img = '".basename($_FILES["fileToUpload"]["name"])."' AND data_insercao = '".$date."'") or die("Error".mysqli_error());
echo "<script>alert('Success!');</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;URL='index.php?pg=3'\" /> ";
echo "<meta http-equiv=\"refresh\" content=\"0;URL='index.php?pg=3'\" /> ";
}
}
SOLVED
What I did to change
$insert=mysqli_query($db, "UPDATE logo SET img = '".basename($_FILES["fileToUpload"]["name"])."', data_insercao = '".$date."'") or die("Error".mysqli_error());
Just had a comma instead of AND
ANDfor,in your query. You could also build your query first, thenechoit for testing purposes, then execute it.