Ciao ragazzi!!!! Ho un problema con l'inserimento di alcuni dati su un datbase MySql.
Qui riporto il codice:
e qui quello che mi restituisce il browser:codice:function edit_imm() { global $conf; global $db; /*UPDATE nomeTabella SET nomeCampo = 'nuovoValore' WHERE id = 'n';*/ $nome = addslashes($_POST['nome']); $tipo = addslashes($_POST['tipo']); $anno = addslashes($_POST['anno']); $mq = addslashes($_POST['mq']); $zona = addslashes($_POST['zona']); $descrizione = addslashes($_POST['descrizione']); $prezzo = addslashes($_POST['prezzo']); $type = $HTTP_POST_FILES["img1"]["type"]; //echo $type; $name = $HTTP_POST_FILES["img1"]["name"]; //echo $name; $tmpname = $HTTP_POST_FILES["img1"]["tmp_name"]; //echo $tmpname; $size = $HTTP_POST_FILES["img1"]["size"] ; //echo $size; $path = $conf[img_path]; // verifico se le foto sono state modificate if ($name) { copy($tmpname, "$path/$name"); $img1=$name; } else $img1 = $immagine1; $type = $HTTP_POST_FILES["img2"]["type"]; //echo $type; $name = $HTTP_POST_FILES["img2"]["name"]; //echo $name; $tmpname = $HTTP_POST_FILES["img2"]["tmp_name"]; //echo $tmpname; $size = $HTTP_POST_FILES["img2"]["size"] ; //echo $size; $path = $conf[img_path]; // verifico se le foto sono state modificate if ($name) { copy($tmpname, "$path/$name"); $img2=$name; } else $img2 = $immagine2; $sql = "UPDATE $conf[dbt_immobili] nome = '$nome', tipo = '$tipo', anno = '$anno', mq = '$mq', zona = '$zona', desc = '$descrizione', descrizione = '$descrizione', prezzo = '$prezzo', img1 = '$img1', img2 = '$img2' WHERE ID = '$_GET[id]'"; if (mysql_query($sql, $db)) { echo " OK"; ?> <script language="javascript"> <!-- function Redirect() { location.href = "immobile.php"; // indica lindirizzo della pagina o del sito al quale vuoi reindirizzare } window.onload=Redirect //--> </script><? } else { echo " ".mysql_errno(); echo " KO"; }
Il problema non è dovuto al fatto della connessione al database e neanche dell'importazione dei dati dal file di configurazione.codice:Ho avuto accesso al database. Array ( [action] => insert ) Array ( [tipo] => BOX [nome] => emu86 [anno] => 165 [mq] => 35 [descrizione] => mnv hv òklhvkhg òfkjlg [zona] => summaga [prezzo] => 1650 [conferma] => conferma ) INSERT INTO immobili (ID, nome, tipo, anno, mq, zona, desc, descrizione, prezzo, img1, img2) VALUES (NULL,'emu86','BOX','165','35','summaga','mnv hv òklhvkhg òfkjlg ','mnv hv òklhvkhg òfkjlg ','1650','','') 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 'desc, descrizione, prezzo, img1, img2) VALUES (NULL,'emu86','BOX','165','35','su' at line 1 KO
Perchè allora non funziona?
Ciao e grazie mille!!!
PS: Per informazione, il numero dell'errore è 1064.
EDIT: Utilizzo PHP 5 e MySql 5.0.20

Rispondi quotando
