ciao a tutti, avrei bisogno di inquadrare la pagina 2.php mi date una mano?
PREMESSA
a) dalla pagina 1.php inserisco i dati relativi ad una struttura turistica.
b) successivamente ho bisogno di caricare anche le relative foto e lo faccio mettendo un link che passa l'ID alla pagina 2 (chiamata foto_es.php)
FOTO_ES.PHP
codice:
<?
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"];
$TINYFILE=$_FILES["tinyimage"]["name"]; //SOSTITUIRE HTTP_POST_FILES
$LARGEFILE=$_FILES["largeimage"]["name"]; // CON FILES
}else{$up="falso";}
if (isset($_GET["id"])){
$id_struttura = $_GET["id"];
}
LINEA 26include ("configurazione.php");
$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>
<?
//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]logo.gif[/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"><a href="Admin.php">Vai
al Menù di Amministrazione </a> </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">
File immagine (jpg, gif) di anteprima.Dimensioni
max: <u>100x100 px</u></p></td>
<td colspan="2" align="right" valign="middle"> <input size="50" type="file" name="tinyimage"></td>
</tr>
<tr>
<td height="40" align="right" valign="middle">
File Immagine (jpg,
gif). Dimensioni max: <u>500x500 px</u></p></td>
<td colspan="2" align="right" valign="middle"> <input size="50" type="file" name="largeimage"></td>
</tr>
<tr>
<td height="35" align="right" valign="bottom"> <p class="Indented">
<input type="hidden" name="upimg" value="<? 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>
<td></td>
</tr>
<tr>
<td height="15"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr align="center" valign="middle">
<td height="55" colspan="5">
<?
$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
//$path="/public";
$save="ko";
$path="/public";
if (($tinyimage != none ) && ($largeimage != none)) {
print("Percorso locale: $tinyimage -- ");
print("Nome del file: $tinyimage -- ");
print("Dimensione del file: $tinyimage_size -- ");
print("Tipo di file: $tinyimage_type --
/n");
print("<HR>
/n");
print("Percorso locale: $largeimage -- ");
print("Nome del file: $largeimage -- ");
print("Dimensione del file: $largeimage_size -- ");
print("Tipo di file: $largeimage_type --
/n");
print("<HR>
/n");
$Filedest="Tiny_ID" .$id_struttura ."_" .$largeimage_name;
if (copy( $tinyimage , $path . "/" .$Filedest )){
print "$tinyimage copiato con successo in $path/$Filedest
";
$POS = strrpos($LARGEFILE,"/");
$FILE = substr($LARGEFILE,$POS);
$save="ok";
}else{print "Errore.. upload non riuscito
";$save="ko";}
$Filedest="Tiny_ID" .$id_struttura ."_" .$largeimage_name;
if (copy( $largeimage , $path . "/" .$Filedest )){
print "$largeimage copiato con successo in $path/$Filedest
";
$save="ok";
}else{print "Errore.. upload non riuscito
";$save="ko";}
unlink($tinyimage);
unlink($largeimage);
}else{print "Errore.. nessun file.
";$save="ko";}
// fine upload primo file
if ($save="ok") {
$stringsql = "INSERT INTO strutture_foto (ID_STRUTTURA, FOTO) VALUES ('$id_struttura','$FILE')";
$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";}
}
?>
</td>
</tr>
<tr>
<td height="25"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="130" colspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<form action="foto_es.php" enctype="multipart/form-data" method="post" name="ELIMINA">
<?
$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'>
<img src=public/tiny_" .$riga_foto["FOTO"] ." width=100 alt='foto n° " .($counter+1) ."'></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>";
}
?>
<tr>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
<td width="100" height="1"></td>
</tr>
</form>
</table></td>
</tr>
</table>
</body>
</html>
d) dato tutto questo mi restituisce il seguente errore
codice:
Warning: main(configurazione.php) [function.main]: failed to open stream: No such file or directory in /web/htdocs/www.xxxx.it/home/xxx/pages/foto_es.php on line 26
Warning: main() [function.include]: Failed opening 'configurazione.php' for inclusion (include_path='.:/php/lib/php/') in /web/htdocs/www.xxx.it/home/xxx/pages/foto_es.php on line 26
Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /web/htdocs/www.xxxx.it/home/xxx/pages/foto_es.php on line 27
Impossibile connettersi al database!
cosa succede???