Sera a tutti,
ho un problema con la mia ultima pagina php, ho controllato più volte il codice, ma non riesco ad individuare l'errore.
La pagina mi da il seguente errore:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Codice PHP:
Codice PHP:
<?php
session_start();
require_once('mysqlconn.php');
mysql_select_db($database, $utenti);
$id = $_SESSION['id'];
if ($_SESSION['stat'] != true)
header('Location: login.php');
$sql = mysql_query("SELECT * FROM utenti WHERE id = '".$id."' ") or die (mysql_error());
$info = mysql_fetch_array($sql);
$nome = $_POST['nome'];
$tipo = $_POST['tipo'];
$nomefile = $_FILES['userfile']['name'];
if(!empty($_FILES["userfile"])) {
foreach ($_FILES["userfile"]["name"] as $indice => $nome) {
if($_FILES["userfile"]["error"][$indice] == 0) { //CONTROLLO NON CI SIANO ERRORI
if($_FILES["userfile"]["size"][$indice] < 1000000) { //CONTROLLO DIMENSIONE MINORE DI 1 MB
//SE I CONTROLLI VANNO A BUON FINE, SALVO NEL DB
$data = addslashes(fread(fopen($_FILES['userfile']['tmp_name'][$indice], "rb"),$_FILES['userfile']['size'][$indice]));
$risultato = mysql_query("INSERT INTO file (utente, nome, tipo, nomefile, file, size, type) VALUES ('".$id."', '".$nome."', '".$tipo."', '".$nomefile."', '".$data."', '".$_FILES['userfile']['size'][$indice]."', '".$_FILES['userfile']['type'][$indice]."' ") or die (mysql_error());
if($risultato) {
echo "File spostato con successo!";
header('Location: home.php');
} else {
die("Errore imprevisto durante lo spostamento dell'immagine!");
}
} else {
die("Il file selezionato è troppo grande, non deve superare 1MB!");
}
} else {
die("Errore imprevisto durante il caricamento dell'immagine!");
}
}
} else {
die("Nessun file selezionato.");
}
?>
Spero che qualche occhio in più possa essere d'aiuto...
Grazie a tutti in anticipo!