Visualizzazione dei risultati da 1 a 3 su 3

Discussione: errore di risposta

  1. #1

    errore di risposta

    non capisco perche la query mi risponde sempre in questo modo

    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 'ORDER BY numero ASC' at line 1

  2. #2
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    Posta tutta la query.

    edit. Mi sorge il dubbio che non abbia stabilito la connessione a mysql nč selezionato il db.

  3. #3

    grazie nicolas

    forse e meglio che ti spieghi il problema. Ho creato un form di ricerca su un dB che contiene una semplicissima tabella con campi del tipo :numero:tipo:data:anno:

    Lo scopo e quello di dare la possibilita al visitarore di scegliere il criterio di selezione: ad esempio dutti i documenti di tipo B dell'anno 2009. Ovviamente nel form ci sono dei menu a tendina che ti danno la possibilitā di scegliere i tipi di documenti, il numero. o l'anno.

    Il problema secondo me sta nella query..non riesco a farle gestire piu domande al dB
    Cmq ti posto il codice forse e meglio.

    <?php
    mb_http_input("iso-8859-1");
    mb_http_output("iso-8859-1");
    ?>
    <?php require_once('Connections/databse.php'); ?>
    <?php
    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

    mysql_select_db($database_databse, $databse);
    $query_Recordset1 = "SELECT * FROM delibere WHERE delibere.numero=delibere.numero OR delibere.tipo=delibere.tipo OR delibere.anno=delibere.anno OR delibere.oggetto=delibere.oggetto ORDER BY delibere.numero ASC";
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $databse) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);

    if (isset($_GET['totalRows_Recordset1'])) {
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
    $all_Recordset1 = mysql_query($query_Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    }
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

    $currentPage = $_SERVER["PHP_SELF"];

    $queryString_Recordsetnumero = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
    $params = explode("&", $_SERVER['QUERY_STRING']);
    $newParams = array();
    foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordsetnumero") == false &&
    stristr($param, "totalRows_Recordsetnumero") == false) {
    array_push($newParams, $param);
    }
    }
    if (count($newParams) != 0) {
    $queryString_Recordsetnumero = "&" . htmlentities(implode("&", $newParams));
    }
    }
    $queryString_Recordsetnumero = sprintf("&totalRows_Recordsetnumero=%d%s", $totalRows_Recordsetnumero, $queryString_Recordsetnumero);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <style type="text/css">
    <!--
    .Stile3 {font-family: Georgia, "Times New Roman", Times, serif}
    .Stile4 {
    color: #000066;
    font-weight: bold;
    }
    .Stile10 {font-family: Georgia, "Times New Roman", Times, serif; color: #0000CC; font-weight: bold; }
    -->
    </style>
    </head>

    <body>
    <form action="" method="get" enctype="multipart/form-data" name="cerca" id="cerca">
    <table width="600" border="1">
    <tr>
    <td width="68"><div align="center" class="Stile4"><span class="Stile3">delibere</span></div></td>
    <td width="172"></td>
    <td width="23"></td>
    <td width="86"></td>
    <td width="202"></td>
    <td width="9"></td>
    </tr>
    <tr>
    <td><div align="center" class="Stile4"><span class="Stile3">numero</span></div></td>
    <td><input name="numero" type="text" id="numero" value="0">
    </td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td><div align="center" class="Stile4"><span class="Stile3">tipo</span></div></td>
    <td><select name="tipo" class="Stile10" id="tipo">
    <option value="">scegli</option>
    <option value="giunta">delibera di Giunta</option>
    <option value="sindaco">delibera del Sindaco</option>
    </select></td>
    <td></td>
    <td><div align="right"><span class="Stile10">anno</span></div></td>
    <td><select name="anno" id="anno">
    <option>scegli</option>
    <option value="2009">2009</option>
    <option value="2008">2008</option>
    </select>
    </td>
    <td></td>
    </tr>
    <tr>
    <td><div align="center" class="Stile4"><span class="Stile3">data</span></div></td>
    <td>
    </td>
    <td></td>
    <td><div align="right"><span class="Stile10">oggetto</span></div></td>
    <td>
    <input name="oggetto" type="text" id="oggetto2">
    </td>
    <td>
    <input type="submit" name="Submit" value="cerca">
    </td>
    </tr>
    </table>


    </p>
    </form>
    <table width="600" border="1">
    <?php do { ?>
    <tr>
    <td><?php echo $row_Recordset1['numero']; ?></td>
    <td><?php echo $row_Recordset1['tipo']; ?></td>
    <td><?php echo $row_Recordset1['data']; ?></td>
    <td><?php echo $row_Recordset1['anno']; ?></td>
    <td><?php echo $row_Recordset1['oggetto']; ?></td>
    <td></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>


    </p>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.