ciao ragazzi,
questo codice funzionava bene fino all'attuale cambio di server (ora siamo su server dedicato aruba prima su hosting windows di aruba stesso).
ora non funziona alla perfezione. in pratica registra regolarmente i campi ID_CONTATORE e ID_STRUTTURA ma non compila gli altri due (FOTO e DESCRIZIONE). E poi, funziona anche bene la cancellazione dei record.
strano vero???
quindi nn posso pensare che sia la connessione. ma cosa può essere???
a presto, daniele.
codice:
<?php
if (isset($_POST["del_id"])) {
$id_struttura=$_POST["del_id"];
$del_id="vero";
}else{$del_id="falso";}
if (isset($_POST["upimg"])) {
$up="vero";
$id_struttura=$_POST["upimg"];
$LARGEFILE=$_FILES["largeimage"]["name"];
$DESCRIZIONE=$_FILES["descrizione"]["name"]; // CON FILES
}else{$up="falso";}
if (isset($_GET["id"])){
$id_struttura = $_GET["id"];
}
$db_host = "xxxxxxxx";
$db_user = "xxxxxxxxxx";
$db_password = "xxxxxxxxx";
$db_name = "xxxxxxxxxxxxx";
$connection = mysql_pconnect("$db_host","$db_user","$db_password") or die ("Impossibile connettersi al database!");
mysql_select_db("$db_name", $connection) or die("Impossibile accedere al database!");
?>
</head>
<body>
<?php if ($login=="ko") {
echo "<p class=title align=center>ACCESSO NEGATO - LOGIN NON EFFETTUATO</p>";
exit;
}
//eliminazione dell'indirizzo delle foto dal db
if ($del_id=="vero"){
$sql_foto="SELECT strutture_foto.FOTO, strutture_foto.ID_CONTATORE FROM strutture_foto WHERE strutture_foto.ID_STRUTTURA = " .$id_struttura;
$result_foto = mysql_query("$sql_foto", $connection)or die (mysql_error());
$righe_foto = mysql_num_rows($result_foto);
if ($righe_foto!=0) {
$counter=0;
for ($counter=0;$counter<$righe_foto;$counter++){
mysql_data_seek($result_foto,$counter);
$riga=mysql_fetch_assoc($result_foto);
$id=$riga["ID_CONTATORE"];
if (isset($_POST[$id])){
$sqldel="DELETE FROM strutture_foto WHERE strutture_foto.ID_CONTATORE='$id'";
mysql_query("$sqldel",$connection) or die (mysql_error());
}
}
}
}
?>
<table width="1024" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="100" colspan="5" align="center" valign="middle" class="Admin">[img]../images/header-gallery.jpg[/img]</td>
</tr>
<tr align="center" valign="bottom">
<td height="40" colspan="5" class="Title">Inserimento di una Nuova Struttura -(Foto Album)</td>
</tr>
<tr>
<td height="23" colspan="5" valign="top"><hr color="#FF9900" size="5"></td>
</tr>
<tr>
<td height="43" colspan="2" align="center" valign="middle">Pagina 10/10</td>
<td width="622"></td>
<td colspan="2" align="right" valign="bottom"><p align="right" class="Indented">Vai all'elenco Strutture </p></td>
</tr>
<tr>
<td width="166" height="53"></td>
<td width="22"></td>
<td align="center" valign="top">
ATTENZIONE!</p>
Attenersi alle indicazioni riportate nel modulo. L'inserimento di
una foto troppo grande potrebbe compromettere l'operazione di upload del
file ed il layout della pagina.</p></td>
<td width="25"></td>
<td width="189"></td>
</tr>
<tr>
<td height="115"></td>
<td colspan="3" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<form action="foto_es.php" enctype="multipart/form-data" method="post" name="UploadFile">
<tr>
<td width="378" height="40" align="right" valign="middle">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1024000">
</td>
</tr>
<tr>
<td height="40" align="right" valign="middle">
File Immagine (jpg, gif).</p></td>
<td colspan="2" align="right" valign="middle"> <input size="50" type="file" name="largeimage"></td>
</tr>
<tr>
<td height="40" align="right" valign="middle">
Breve Descrizione</p></td>
<td colspan="2" align="left" valign="middle"> <input size="50" type="text" name="descrizione"></td>
</tr>
<tr>
<td height="35" align="right" valign="bottom"> <p class="Indented">
<input type="hidden" name="upimg" value="<?php echo $id_struttura;?>">
<input type="reset" value="Ripristina">
</p></td>
<td width="119" align="left" valign="bottom"><p class="Indented">
<input type="submit" value="Esegui Upload">
</p></td>
<td width="172" align="center" valign="bottom"><font size="-2">* MAX 10 FOTO</font></td>
</tr>
</form>
</table></td>
<?php
$sql_foto="SELECT strutture_foto.FOTO FROM strutture_foto WHERE strutture_foto.ID_STRUTTURA = " .$id_struttura;
$result_foto = mysql_query("$sql_foto", $connection)or die (mysql_error());
$righe_foto = mysql_num_rows($result_foto);
if ($sql_foto<10){
$foto="ok";
}else{
$foto="ko";
}
if (($foto=="ok") && ($up=="vero")) {
//upload dei file e salvataggio nel db
$save="ko";
$a=$_SERVER['DOCUMENT_ROOT'];
$path = "/gestionale/public";
if (($largeimage != none)) {
print("Percorso locale: $largeimage -- ");
print("Nome del file: $largeimage -- ");
print("Dimensione del file: $largeimage_size -- ");
print("Tipo di file: $largeimage_type --
/n");
print("<HR>
/");
$Filedest="Salento_str" .$id_struttura ."_" .$largeimage_name;
if (copy( $largeimage , $path . "/" .$Filedest )){
print "$largeimage copiato con successo in $path/$Filedest
";
$POS = strrpos($LARGEFILE,"/");
$FILE = substr($LARGEFILE,$POS);
$save="ok";
}else{print "Errore.. upload non riuscito
";$save="ko";}
unlink($largeimage);
}else{print "Errore.. nessun file.
";$save="ko";}
// fine upload primo file
if ($save="ok") {
$stringsql = "INSERT INTO strutture_foto (ID_STRUTTURA, FOTO, DESCRIZIONE) VALUES ('$id_struttura','$FILE','$descrizione')";
$result_2 = mysql_query($stringsql, $connection) or die (mysql_error());
}
}else{
if ($foto=="ko")
{echo $foto ."-" .$up ."SI E' RAGGIUNTO IL NUMERO MASSIMO DI FOTO CONSENTITE";}
}
?>
<form action="foto_es.php" enctype="multipart/form-data" method="post" name="ELIMINA">
<?php
$sql_foto="SELECT strutture_foto.FOTO, strutture_foto.ID_CONTATORE FROM strutture_foto WHERE strutture_foto.ID_STRUTTURA = " .$id_struttura;
$result_foto = mysql_query("$sql_foto", $connection)or die (mysql_error());
$righe_foto = mysql_num_rows($result_foto);
$counter = 0;
if ($righe_foto != 0) {
echo "<tr>";
for ($counter=0;$counter<$righe_foto;$counter++){
mysql_data_seek($result_foto,$counter);
$riga_foto = mysql_fetch_assoc($result_foto);
if ($counter<10){
$idfoto=$riga_foto["ID_CONTATORE"];
echo "<td width=100 height=100 align=center valign=middle><input type=checkbox name='$idfoto' value='$idfoto'>
<a href='/gestionale/public/Salento_str" .$id_struttura ."_" .$riga_foto["FOTO"] ."' target='_blank' >
<img src=/gestionale/public/Salento_str" .$id_struttura ."_" .$riga_foto["FOTO"] ." width=100 alt='foto n° " .($counter+1) ."'></a></td>";
}
}
echo "</tr>";
echo "<tr><td colspan=5 height=25 align=right><input type=hidden name=del_id value='$id_struttura'><input type=reset value='Ripristina'></td><td colspan=5 height=25 align=left><input type=submit value='Elimina Selezionati'></td></tr>";
}
?>
</form>
</table></td>
</tr>
</table>