Niente, mi porta questo errore:
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
posto i codici delle pagine perchè sto diventando pazzo:
PAG1:
Codice PHP:
<?php include 'paginazione.php'; $DB_host = 'xxx'; $DB_user = 'xxx'; $DB_password = 'xxx'; $DB_name = 'xxxx'; $righe_per_pagina = 6; $url_base = "artisti.php"; $pagine_vicine = 5; // ---------------------------------------------------------------- // C O N N E S S I O N E A L D A T A B A S E $link = mysql_connect($DB_host, $DB_user, $DB_password); if (!$link) { die ('Non riesco a connettermi: ' . mysql_error()); } $db_selected = mysql_select_db($DB_name, $link); if (!$db_selected) { die ("Errore nella selezione del database: " . mysql_error()); } // ---------------------------------------------------------------- // C A L C O L O D E L N U M E R O D I P A G I N E // ricavo il numero totale di record $query = "SELECT COUNT(*) FROM artisti"; $result = mysql_query($query); // record complessivi $tot_righe = mysql_result($result,0); // totale pagine $tot_pagine = ceil($tot_righe / $righe_per_pagina); // ---------------------------------------------------------------- // P A G I N A C O R R E N T E $pagina_corrente = isset($_GET['pag']) ? (int)$_GET['pag'] : 1; // se la pagina corrente è minore di 1 if($pagina_corrente < 1) { header('location: ' . $url_base); exit(); } // se la pagina corrente è maggiore dell'ultima pagina if($pagina_corrente > $tot_pagine) { header('location: ' . crea_url($url_base, $tot_pagine)); exit(); } // ---------------------------------------------------------------- // E S T R A Z I O N E D E I R E C O R D // calcolo la prima riga da estrarre con la query $prima_riga = ($pagina_corrente - 1) * $righe_per_pagina; $query = "SELECT * FROM artisti ORDER BY nome ASC LIMIT $prima_riga, $righe_per_pagina"; $result = mysql_query($query); if (!$result) { die("Errore nella query $query: " . mysql_error()); } $rsArt = array(); while ($row = mysql_fetch_assoc($result)) { $rsArt[] = $row; } // creazione dei link di paginazione $link_paginazione = paginazione($tot_pagine, $url_base, $pagina_corrente, $pagine_vicine); ?> <?php require_once('Connections/verba.php'); ?> <?php mysql_select_db($database_verba, $verba); $query_rsNews = "SELECT * FROM catalogo WHERE artista = (SELECT artista FROM artisti WHERE news_id=$news_id)"; $rsNews = mysql_query($query_rsNews, $verba) or die(mysql_error()); $row_rsNews = mysql_fetch_assoc($rsNews); $totalRows_rsNews = mysql_num_rows($rsNews); ?>
la variabile di pagina1 da inviare a pagina2:
Codice PHP:
[url="pagina2.php?artisti=<?php echo $row_rsArt['news_id']; ?>&catalogo=<?php echo $row_rsNews['artista']; ?>"][/url]
la pagina 2 che ovrà ricevere le 2 variabili:
Codice PHP:
<?php require_once('Connections/verba.php'); ?> <?php $colname_rsArt = "-1"; if (isset($_GET['artisti'])) { $colname_rsArt = (get_magic_quotes_gpc()) ? $_GET['artisti'] : addslashes($_GET['artisti']); } mysql_select_db($database_verba, $verba); $query_rsArt = sprintf("SELECT * FROM artisti WHERE news_id = %s", $colname_rsArt); $rsArt = mysql_query($query_rsArt, $verba) or die(mysql_error()); $row_rsArt = mysql_fetch_assoc($rsArt); $totalRows_rsArt = mysql_num_rows($rsArt); ?> <?php require_once('Connections/verba.php'); ?> <?php $colname_rsNews = "-1"; if (isset($_GET['catalogo'])) { $colname_rsNews = (get_magic_quotes_gpc()) ? $_GET['catalogo'] : addslashes($_GET['catalogo']); } mysql_select_db($database_verba, $verba); $query_rsNews = sprintf("SELECT * FROM catalogo WHERE artista = %s", $colname_rsNews); $rsNews = mysql_query($query_rsNews, $verba) or die(mysql_error()); $row_rsNews = mysql_fetch_assoc($rsNews); $totalRows_rsNews = mysql_num_rows($rsNews); ?>