sto diventanto pazzo
VVoVe:
codice:
<?php
include('Connessione.php');
$risultato=mysql_query("Select* from jgames,click where jgames.id = click.id") or die ("non trovo la tabella");
$numRecord=mysql_num_rows($risultato);
//$record['file']." il mio file esempio pippo.jpg
echo"<a href='".$record['file']."'>[img]img/scarica.gif[/img]";
function forceDownload( $risultato ) {
/**
* Function forceDownload:
* download any type of file if it exists and is readable
* -------------------------------------
* @author Andrea Giammarchi
* @date 18/01/2005 [13/04/2005]
* @compatibility PHP >= 4.3.0
*/
if( file_exists( $file ) == true && is_readable( $file ) == true ) {
$filename = &basename( $file );
if( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
$parsename = &explode( '.', $filename );
$last = count( $parsename ) - 1;
$filename = &implode( '%2E', array_slice( $parsename, 0, $last ) );
$filename .= '.'.$parsename[$last];
}
$content = &file_get_contents( $file );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
header( 'Content-Length:'.strlen( $content ) );
header( 'Content-Transfer-Encoding: binary' );
echo $content;
exit(0);
}
}
//controllo se la variabile id_game è stata passata ed è di tipo intero, poi
//assegno il suo valore a $id ed eseguo la query per ottenere l'id richiesto
if(isset($_GET['id_game']) && (int)$_GET['id_game']) {
$id = $_GET['id_game'];
$categoria = $_GET['categoria'];
$sql = mysql_query("SELECT * FROM click WHERE id = '$id'") or die(mysql_error());
//se nalla tabella "click" l'id richiesto non è presente lo inserisco e imposto
//il valore a 1. Se invece l'id esiste già allora lo incremento soltanto.
$query = (!mysql_num_rows($sql))
? "INSERT INTO click VALUES ('$id', 1)"
: "UPDATE click SET num_click = num_click + 1 WHERE id = '$id'";
//eseguo la query per l'aggiornamento del record
mysql_query($query) or die(mysql_error());
//recupero il nome del file dalla tabella dedicata (ovviamente associato all'id_game)
$sql2 = mysql_query("SELECT * FROM jgames WHERE id = '$id'") or die(mysql_error());
$file = mysql_fetch_object($sql2);
// ...fine ;)
forceDownload($file->nome);
}
?>
cosa sbaglio??