- Home
- Categorie
- Coding e Sistemistica
- PHP
- Conteggio record
-
che errore ti da?
-
Questo qui:
Parse error: syntax error, unexpected ',' in D:\inetpub\webs.....
-
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC". GetSQLValueString($colname_rs_sottomenu, "text")
-
Mi da errore
Parse error: syntax error, unexpected T_VARIABLE in D:\inetpub\webs
sulla riga:
$result = mysql_query($query) or die (mysql_error());ho fatto così, posto il codice completo:
[PHP]
$colname_rs_sottomenu = "-1";
if (isset($_GET['id_menu'])) {
$colname_rs_sottomenu = $_GET['id_menu'];
}mysql_select_db($database_conn, $conn);
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC". GetSQLValueString($colname_rs_sottomenu, "text")
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result));[/PHP]
[PHP]
//e poi stampo il sottomenù<?php echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; ?>
[/PHP]
-
Prova a mettere questa query
$query = "SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC";
-
Mi da errore dopo la fine del codice.
Parse error: syntax error, unexpected $end in D:\inetpub\webs...
Mi spiace che ti stia facendo perdere tempo, se è una cosa complicata da risolvere potrei lasciar perdere.
-
riposta tutto il codice
-
Questo è la prima parte
[PHP]
<?php require_once('Connections/conn.php'); ?>
<?php mysql_query('set names utf8');?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_conn, $conn);
$query_rs_menu = "SELECT * FROM menu ORDER BY nome_menu ASC";
$rs_menu = mysql_query($query_rs_menu, $conn) or die(mysql_error());
$row_rs_menu = mysql_fetch_assoc($rs_menu);
$totalRows_rs_menu = mysql_num_rows($rs_menu);$colname_rs_sottomenu = "-1";
if (isset($_GET['id_menu'])) {
$colname_rs_sottomenu = $_GET['id_menu'];
}mysql_select_db($database_conn, $conn);
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC")
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result));$maxRows_rs_prodotti = 25;
$pageNum_rs_prodotti = 0;
if (isset($_GET['pageNum_rs_prodotti'])) {
$pageNum_rs_prodotti = $_GET['pageNum_rs_prodotti'];
}
$startRow_rs_prodotti = $pageNum_rs_prodotti * $maxRows_rs_prodotti;mysql_select_db($database_conn, $conn);
$query_rs_prodotti = "SELECT * FROM prodotti ORDER BY id DESC";
$query_limit_rs_prodotti = sprintf("%s LIMIT %d, %d", $query_rs_prodotti, $startRow_rs_prodotti, $maxRows_rs_prodotti);
$rs_prodotti = mysql_query($query_limit_rs_prodotti, $conn) or die(mysql_error());
$row_rs_prodotti = mysql_fetch_assoc($rs_prodotti);if (isset($_GET['totalRows_rs_prodotti'])) {
$totalRows_rs_prodotti = $_GET['totalRows_rs_prodotti'];
} else {
$all_rs_prodotti = mysql_query($query_rs_prodotti);
$totalRows_rs_prodotti = mysql_num_rows($all_rs_prodotti);
}
$totalPages_rs_prodotti = ceil($totalRows_rs_prodotti/$maxRows_rs_prodotti)-1;$queryString_rs_prodotti = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rs_prodotti") == false &&
stristr($param, "totalRows_rs_prodotti") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rs_prodotti = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rs_prodotti = sprintf("&totalRows_rs_prodotti=%d%s", $totalRows_rs_prodotti, $queryString_rs_prodotti);
?>[/PHP]
e questo è la parte completa del menù con il sottomenù
[PHP]
<div class="menu" id="menu">
<div class="titolocategoria" id="titmenu">Categorie</div>
<div class="categorie" id="categorie">
<div class="tuttomenu" id="tuttomenu">
<?php do { ?>
<div id="menuprincipale"><a href="sottomenu.php?id_menu=<?php echo $row_rs_menu ['id']; ?>" class="testoMENU"> <?php echo ($row_rs_menu['nome_menu']); ?></a></div>
<?php if ($row_rs_menu['id'] == $colname_rs_sottomenu){?>
<?php do { ?>
<div> <a href="prodotti.php?$=<?php echo $row_rs_sottomenu['id_menu']; ?>&$!=<?php echo $row_rs_sottomenu['id']; ?>" class="testoSOTTOMENU"><img src="img/minibutton.png" width="12" height="12" vspace="5" border="0" align="top" /><?php
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; ?></a></div></div>
[/PHP]
-
questo è un ciclo
[PHP]while ($row = mysql_fetch_array($result)); [/PHP]non devi mettere il punto e virgola ma le parentesi graffe
[PHP]while ($row = mysql_fetch_array($result)){
// codice da stampare
}
[/PHP]
al suo interno tutto il codice del menu da stampare, quello che preleva dal database
-
Ho unito il codice in questo modo, però l'errore è quello di prima:
arse error: syntax error, unexpected T_VARIABLE in D:\inetpub\web... alla riga di codice$result = mysql_query($query) or die (mysql_error());
[PHP]
<?php
$colname_rs_sottomenu = "-1";
if (isset($_GET['id_menu'])) {
$colname_rs_sottomenu = $_GET['id_menu'];
}
mysql_select_db($database_conn, $conn);
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC")
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; ?></a>
}
[/PHP]
-
il punto e virgola alla fine della query ci va:
$query "SELECT ......... ";
-
Ho corretto così, ma da l'errore:
Parse error: syntax error, unexpected $end in D:\inetpub\webs...
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC");
-
guarda qui:
[PHP]
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; ?></a>
}
[/PHP]c'è la chiusura della graf fuori dal codice php devi metterlo all'interno
[PHP]
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) </a>";
}?>
[/PHP]
-
Ho corretto quella parte come hai detto:
[PHP]
<?php
$colname_rs_sottomenu = "-1";
if (isset($_GET['id_menu'])) {
$colname_rs_sottomenu = $_GET['id_menu'];
}
mysql_select_db($database_conn, $conn);
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC");
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; }?>
[/PHP]però mi da sempre errore alla fine, dopo l'ultima riga del codice.
Parse error: syntax error, unexpected $end in D:\inetpub\webs...
-
riposta tutto il codice modificato, hai un tag di troppo
-
Questa è la prima parte
[PHP]
<?php require_once('Connections/conn.php'); ?>
<?php mysql_query('set names utf8');?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_conn, $conn);
$query_rs_menu = "SELECT * FROM menu ORDER BY nome_menu ASC";
$rs_menu = mysql_query($query_rs_menu, $conn) or die(mysql_error());
$row_rs_menu = mysql_fetch_assoc($rs_menu);
$totalRows_rs_menu = mysql_num_rows($rs_menu);$maxRows_rs_prodotti = 25;
$pageNum_rs_prodotti = 0;
if (isset($_GET['pageNum_rs_prodotti'])) {
$pageNum_rs_prodotti = $_GET['pageNum_rs_prodotti'];
}
$startRow_rs_prodotti = $pageNum_rs_prodotti * $maxRows_rs_prodotti;mysql_select_db($database_conn, $conn);
$query_rs_prodotti = "SELECT * FROM prodotti ORDER BY id DESC";
$query_limit_rs_prodotti = sprintf("%s LIMIT %d, %d", $query_rs_prodotti, $startRow_rs_prodotti, $maxRows_rs_prodotti);
$rs_prodotti = mysql_query($query_limit_rs_prodotti, $conn) or die(mysql_error());
$row_rs_prodotti = mysql_fetch_assoc($rs_prodotti);if (isset($_GET['totalRows_rs_prodotti'])) {
$totalRows_rs_prodotti = $_GET['totalRows_rs_prodotti'];
} else {
$all_rs_prodotti = mysql_query($query_rs_prodotti);
$totalRows_rs_prodotti = mysql_num_rows($all_rs_prodotti);
}
$totalPages_rs_prodotti = ceil($totalRows_rs_prodotti/$maxRows_rs_prodotti)-1;$queryString_rs_prodotti = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rs_prodotti") == false &&
stristr($param, "totalRows_rs_prodotti") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rs_prodotti = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rs_prodotti = sprintf("&totalRows_rs_prodotti=%d%s", $totalRows_rs_prodotti, $queryString_rs_prodotti);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "......w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=".......w3.org/1999/xhtml">
[/PHP]eliminato qualcosa per semplificare
questa è la seconda parte
[PHP]
<div class="contenuto" id="contenuto">
<div class="menu" id="menu">
<div class="titolocategoria" id="titmenu">Categorie</div>
<div class="categorie" id="categorie">
<div class="tuttomenu" id="tuttomenu">
<?php do { ?>
<div id="menuprincipale"><a href="sottomenu.php?id_menu=<?php echo $row_rs_menu ['id']; ?>" class="testoMENU"> <?php echo ($row_rs_menu['nome_menu']); ?></a></div>
<?php if ($row_rs_menu['id'] == $colname_rs_sottomenu){?>
<?php do { ?>
<div> <a href="prodotti.php?$=<?php echo $row_rs_sottomenu['id_menu']; ?>&$!=<?php echo $row_rs_sottomenu['id']; ?>" class="testoSOTTOMENU"><img src="img/minibutton.png" width="12" height="12" vspace="5" border="0" align="top" /><?php
//parte interessata
$colname_rs_sottomenu = "-1";
if (isset($_GET['id_menu'])) {
$colname_rs_sottomenu = $_GET['id_menu'];
}
mysql_select_db($database_conn, $conn);
$query = ("SELECT COUNT(id),sottomenu FROM sottomenu WHERE id_menu = %s ORDER BY sottomenu ASC");
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
echo $row_rs_sottomenu['sottomenu'] . " ( " . $totalRows_rs_sottomenu . " ) "; }?></a></div></div> </div> <div class="motore" id="motore"> <form id="form1" name="form1" method="get" action="risultati_ricerca.php"> <span class="testoMENU">Cerca un prodotto</span><br /> <input name="ricerca" type="text" id="ricerca" size="14" /> <input name="cerca" type="submit" class="testoprivacy" id="cerca" value="cerca" /> </form> </div> </div> <div class="listaprodotti" id="listaprodotti"> <div class="titolocategoria" id="vetrina">La Vetrina <span class="footer">(ultimi prodotti inseriti)</span></div> <table align="center" > <tr> <td><?php do { ?> <table > <tr> <?php
$rs_prodotti_endRow = 0;
$rs_prodotti_columns = 5; // number of columns
$rs_prodotti_hloopRow1 = 0; // first row flag
do {
if($rs_prodotti_endRow == 0 && $rs_prodotti_hloopRow1++ != 0) echo "<tr>";
?>
<td><table width="100" align="center" cellpadding="1" cellspacing="6">
<tr valign="bottom">
<th width="100" height="120" align="center" scope="col">
<a href="image_files/<?php echo $row_rs_prodotti['foto']; ?>" title="Codice: <?php echo $row_rs_prodotti['codice']; ?>" class="testoprivacy" rel="lightbox[roadtrip]"><img src="image_files/thumbs/<?php echo $row_rs_prodotti['foto']; ?>" alt="" border="0" align="bottom" /></a><br /></th>
</tr>
<tr>
<td align="center" valign="bottom" class="testoCATEGORIA_NERO" scope="col">
<span class="testo" onclick="window.open('dettagli.php?$!!=<?php echo $row_rs_prodotti['id']; ?>','prova','height=510,width=630,resizable=no ,scrollbars=no,top=100,left=350').focus(); return false;"><a href="#"class="testoCODICE"><?php echo $row_rs_prodotti['codice']; ?></a></span></td>
</tr>
</table></td>
<?php $rs_prodotti_endRow++;
if($rs_prodotti_endRow >= $rs_prodotti_columns) {
?>
</tr>
<?php
$rs_prodotti_endRow = 0;
}
} while ($row_rs_prodotti = mysql_fetch_assoc($rs_prodotti));
if($rs_prodotti_endRow != 0) {
while ($rs_prodotti_endRow < $rs_prodotti_columns) {
echo("<td> </td>");
$rs_prodotti_endRow++;
}
echo("</tr>");
}?>
</table>
<?php } while ($row_rs_prodotti = mysql_fetch_assoc($rs_prodotti)); ?></td>
</tr>
</table>
<table width="689" border="0" cellpadding="1" cellspacing="1">
<tr>
<th colspan="5" align="right" scope="col"><hr /></th>
</tr>
<tr>
<th width="60" align="right" scope="col">
<?php if ($pageNum_rs_prodotti > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rs_prodotti=%d%s", $currentPage, 0, $queryString_rs_prodotti); ?>" class="testoCATEGORIA_NERO">Primo</a>
<?php } // Show if not first page ?></th>
<th width="84" scope="col">
<?php if ($pageNum_rs_prodotti > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rs_prodotti=%d%s", $currentPage, max(0, $pageNum_rs_prodotti - 1), $queryString_rs_prodotti); ?>" class="testoCATEGORIA_NERO">Indietro</a>
<?php } // Show if not first page ?></th>
<th width="200" scope="col"> <span class="testoCATEGORIA_NERO"> Prodotto da </span><span class="testoCATEGORIA"><?php echo ($startRow_rs_prodotti + 1) ?></span> <span class="testoCATEGORIA_NERO">a</span> <span class="testoCATEGORIA"><?php echo min($startRow_rs_prodotti + $maxRows_rs_prodotti, $totalRows_rs_prodotti) ?></span> <span class="testoCATEGORIA_NERO">su</span> <span class="testoCATEGORIA"><?php echo $totalRows_rs_prodotti ?></span></th>
<th width="53" scope="col"><?php if ($pageNum_rs_prodotti < $totalPages_rs_prodotti) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rs_prodotti=%d%s", $currentPage, min($totalPages_rs_prodotti, $pageNum_rs_prodotti + 1), $queryString_rs_prodotti); ?>" class="testoCATEGORIA_NERO">Avanti</a>
<?php } // Show if not last page ?></th>
<th width="89" align="left" scope="col">
<?php if ($pageNum_rs_prodotti < $totalPages_rs_prodotti) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rs_prodotti=%d%s", $currentPage, $totalPages_rs_prodotti, $queryString_rs_prodotti); ?>" class="testoCATEGORIA_NERO">Ultimo</a>
<?php } // Show if not last page ?></th>
</tr>
</table>
</div>
</div><div class="soprafooter" id="soprafooter">
<div class="materiali" id="materiali"><img src="img/materiali.jpg" width="303" height="179" border="0" /><span class="testomateriali"><strong>I MATERIALI</strong></span><span class="testoCATEGORIA"><br />
<br />
</span><span class="testomateriali">I materiali con<br />
cui li realizziamo i nostri prodotti sono di assoluta qualità,
in modo da garantirne la massima durata nel tempo...</span></div>
<div class="testomateriali" id="lavorazione"><img src="img/lavorazione.jpg" width="302" height="180" border="0" /><strong>LAVORAZIONE</strong><br />
<br />
Massima attenzione per curare i nostri prodotti nei minimi particolari per soddisfare le esigenze di ogni cliente...<br />
</div></div>
<!-- InstanceEndEditable --><!-- INIZIO FOOTER -->
<div class="footer" id="footer">Copyright 2010 Tutti i diritti riservati - Bottonificio Paola s.a.s. - P.IVA 01340071214 - Tel. +39 081. 505.47.54 - Email <a href="mailto:[email protected]" class="footer">[email protected]</a></div>
<div class="testomenucss" id="menucss"><a href="index.php">Home</a> | <a href="dovesiamo.php">Dove Siamo</a> | <a href="sottomenu.php">Catalogo</a> | <a href="info.php">Info & Contatti</a></div><!-- INIZIO UTENTI ONLINE -->
<div class="footer" id="utentionline"><span class="claudio">
<a href="admin.php"><img src="img/key.gif" width="32" height="16" border="0" /></a><br />
<br />
<? @include("counter/todoocount.php"); ?>
<br />
</div>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rs_menu);mysql_free_result($rs_prodotti);
mysql_free_result($rs_sottomenu);
?>
[/PHP]