mi da il seguente errore:Codice PHP:echo "
<form method=post action=\"$_SERVER[PHP_SELF]\">
<table>
<tr>
<td>
<caption>Inserimento nuovi prodotti </caption>
</td>
</tr>
</table>
<hr>
";
for($j=0;$j<$i;$j++)
{
echo "
<table>
<tr>
<td>Marca</td>
<td><input type=text name=marca></td>
</tr>
<tr>
<td>Modello</td>
<td><input type=text name=modello></td>
</tr>
<tr>
<td>Colore</td>
<td><input type=text name=tipo></td>
</tr>
<tr>
<td>Origine</td>
<td><input type=text name=origine></td>
</tr>
<tr>
<td>Disponibilit?/td>
<td><input type=text name=qt></td>
</tr>
<tr>
<td>Prezzo Privato</td>
<td><input type=text name=prezzo></td>
</tr>
<tr>
<td>Prezzo Azienda</td>
<td><input type=text name=prezzoaz></td>
</tr>
<tr>
<td>Prezzo Rivenditori</td>
<td><input type=text name=prezzoriv></td>
</tr>
</table>
<hr>
";
}
echo "
<table>
<tr>
<td>
<input type=hidden name=id_categorie value=$id>
<input type=submit name=submit value=Edita>
</td>
</tr>
</table>
</form>
</center>
";
echo "</td>";
include 'include/right.inc.php';
include 'include/footer.inc.php';
}
else if($_POST)
{
$marca=addslashes($_POST['marca']);
$modello=addslashes($_POST['modello']);
$tipo=addslashes($_POST['tipo']);
$origine=addslashes($_POST['origine']);
$qt=addslashes($_POST['qt']);
$prezzo=addslashes($_POST['prezzo']);
$prezzoaz=addslashes($_POST['prezzoaz']);
$prezzoriv=addslashes($_POST['prezzoriv']);
$id_categorie=addslashes($_POST['id_categorie']);
include 'include/conf.inc.php';
function prepareSqlText(&$gpc) {
get_magic_quotes_gpc() && $gpc = stripslashes($gpc);
$gpc = mysql_escape_string($gpc);
}
function prepareSqlVar(&$var) {
if (is_array($var)) {
array_walk($var, 'prepareSqlVar');
} else {
prepareSqlText($var);
}
}
// Prepara TUTTI i post per MySQL
prepareSqlVar($_POST);
// Questi i campi da inserire nella tabella
$fields = array('marca', 'modello', 'tipo', 'origine', 'qt', 'prezzo', 'prezzoaz', 'prezzoriv','id_categorie');
// Questi i valori
for ($n = 0; $n < count($_POST['id']); ++ $n) {
foreach ($fields as $field) {
$row[$field] = $_POST[$field][$n];
}
$values[$n] = "('" . implode("','", $row) . "')";
}
// Questa la query
$query = 'INSERT INTO tbl_prodotti (`' . implode('`,`', $fields) . '`) VALUES ' . implode(',', $values);
// Questo per vedere come è fatta la query insert con più righe
echo "<pre>$query</pre>";
// Esecuzione della query
mysql_query($query) || die(mysql_error());
}
INSERT INTO tbl_prodotti (`marca`,`modello`,`tipo`,`origine`,`qt`,`prezzo`, `prezzoaz`,`prezzoriv`,`id_categorie`) VALUES
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
l'hai provato te?
grazie per la disp.

Rispondi quotando