Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 19 su 19
  1. #11
    Utente di HTML.it L'avatar di clasku
    Registrato dal
    Aug 2006
    Messaggi
    3,197
    come puoi notare, $location è vuota... Quindi controlla il codice dove la valorizzi...

    PS: te lo avevo già scritto anche questo... Forse però è meglio essere ripetitivi...

  2. #12
    credo proprio che il campo location sia vuoto. Dai link che hai postato in alto tu passi la location allo script php tramite GET, quindi assicurati di recuperare il campo location con:

    $location = $_GET['location']

    altrimenti la variable $location risulta vuota e la query ritorna un ResultSet vuoto
    V.I.S.T.A. --> Virus Inside, Switch To Apple

  3. #13
    Ricapitolando, $location è vuota ed io scriverei così la query:

    $query= "SELECT * FROM events WHERE location = '".$location."';

    Spesso, quando la scrivevo $location compresa nei doppi apici, mi dava dei problemi

    Ciau

  4. #14
    Utente di HTML.it
    Registrato dal
    Feb 2012
    Messaggi
    16
    grazie a tutti per i suggerimenti, @clasku scusa hai ragione mi sono fatto prendere dall'impazienza
    Allora, ho provato ad aggiungere

    $location = $_GET['location']
    dopo il
    $id = substr($_GET['id'],0,$maxLen);
    già presente ma mi da questo errore:

    Parse error: syntax error, unexpected T_INCLUDE in /home/openopen/public_html/eventi/event2.php on line 28

    naturalmente ho provato tutti i vostri suggerimenti compreso togliere
    mysql_close(); e anche gli apici in varie salse.

    non so più cosa pensare, a questo punto posto il codice completo e funzionante (ci sono anche altre variabili nella query e tutto funziona)

    solo sostituendo nella query id=$id con location=$location (con e senza apici) non va più.

    Codice PHP:
    <?php

    // limit the id lenth to 6 characters... added security.  If you think you'll have more than 999,999 events, you can increase this number.
    $maxLen 6;
    $id substr($_GET['id'],0,$maxLen);

    //Connect To Database
    include("admin/config.php");

    mysql_connect($dbhost,$dbuser,$dbpass) OR DIE ('Unable to connect to database! Please try again later.');
    mysql_select_db($dbname) or die( "Unable to select database");

    mysql_query("SET CHARACTER SET utf8");
    mysql_query("SET NAMES utf8");
            
    //minimized SQL injection attacks
    $id mysql_real_escape_string($id);

    //if the event is in the future, print it out
    $query="SELECT * FROM events WHERE location = '".$location."'
    AND ((year_opening >= 
    $current_year AND month_opening > $current_month
    OR (year_opening >= 
    $current_year AND month_opening = $current_month AND day_opening >= $current_day)) 
    ORDER BY year, month, day LIMIT 0, 
    $maxnum";

    $result=mysql_query($query);
    //$num=mysql_numrows($result);

    echo $query;

    mysql_close();

    $i=0;

    //Get all the data and assign variables
    $event=mysql_result($result,$i,"event");
    $titolonuova=mysql_result($result,$i,"titolonuova");
    $hour=mysql_result($result,$i,"hour");
    $minute=mysql_result($result,$i,"minute");
    $ampm=mysql_result($result,$i,"ampm");
    $month=mysql_result($result,$i,"month");
    $day=mysql_result($result,$i,"day");
    $year=mysql_result($result,$i,"year");
    $datenuova=mysql_result($result,$i,"datenuova");
    $month_opening=mysql_result($result,$i,"month_opening");
    $day_opening=mysql_result($result,$i,"day_opening");
    $year_opening=mysql_result($result,$i,"year_opening");
    $hour_opening=mysql_result($result,$i,"hour_opening");
    $minute_opening=mysql_result($result,$i,"minute_opening");
    $ampm_opening=mysql_result($result,$i,"ampm_opening");
    $month_end=mysql_result($result,$i,"month_end");
    $day_end=mysql_result($result,$i,"day_end");
    $year_end=mysql_result($result,$i,"year_end");
    $month_show=mysql_result($result,$i,"month_show");
    $day_show=mysql_result($result,$i,"day_show");
    $year_show=mysql_result($result,$i,"year_show");
    $location=mysql_result($result,$i,"location");
    $address=mysql_result($result,$i,"address");
    $townn=mysql_result($result,$i,"town");
    $email=mysql_result($result,$i,"email");
    $phone=mysql_result($result,$i,"phone");
    $link=mysql_result($result,$i,"link");
    $link_name=mysql_result($result,$i,"link_name");
    $description=mysql_result($result,$i,"description");
    $descriznuova=mysql_result($result,$i,"descriznuova");
    $html=mysql_result($result,$i,"html");


    // removes slashes
    $description=stripslashes($description);


    //replaces carriage returns with html line breaks
    if ($html =="0") {
    $description=preg_replace("/\n/","
    "
    , ($description));
    }

    // removes the first zero from the hour.  We need the zero at first, to keep the numbering in order.  
    //Of course the number ten needs the zero left in.
    if ($hour !="10") {
    $hour=preg_replace("/0/","", ($hour));
    }
    ?>

    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="events.css" rel="stylesheet" type="text/css">
    <title><?php echo $event?></title>
    </head>
    <body>

    <center>
    <div class="myBox">
    <font color="#660066">o<big>pen<sup>o</sup>pen</big><sup>[size="1"]&copy[/size]</sup>[size="1"]<small> mobile[/size]</small></font>
    </div>
    <hr>

    </center>
    [size="1"][url="../index.html"]<font color="#990066">home</font>[/url] < [url="../openopen/torino.html"]<font color="#990066">turin</font>[/url] < [url="torino.php"]<font color="#990066">opening</font>[/url]
     < <?php echo $location?>[/size]
    <hr>
    <div class="main_area">

    <?php

    // removes the first zero from the hour.  We need the zero at first, to keep the numbering in order.  
    //Of course the number ten needs the zero left in.
    if ($hour !="10") {
    $hour=preg_replace("/0/","", ($hour));
    }

    if (
    $hour_opening !="10") {
    $hour_opening=preg_replace("/0/","", ($hour_opening));
    }

    if ((
    $hour_opening =='') && ($minute_opening =='') && ($ampm_opening =='')) { $opening_time ='';}
    else { 
    $opening_time" - $hour_opening:$minute_opening $ampm_opening"; }

    if ((
    $month_end =='') && ($day_end =='') && ($year_end =='')) { $end_date ='';}
    else { 
    $end_date"- $month_end/$day_end/$year_end"; }

    // Here is where we actually print out the events.
    echo "    <div class=\"myBoxEvent\">[size="1"]
    [b]
    $location[/b] 

    $address 
    phone: 
    $phone 

    [email='
    $email']$email[/email] 

    [url='
    $link']$link_name[/url][/size]</div>

    current: 
    [b]
    $event[/b] 

    $day/$month/$year $day_end/$month_end/$year_end/  


    <span style=\"text-transform: none\">
    $description </span><hr>

    upcoming: 
    [b]
    $titolonuova[/b] 

    $datenuova 


    <span style=\"text-transform: none\">
    $descriznuova </span><hr>


    $html ";

    ?>

    </div>

    </body>
    </html>

  5. #15
    E dov'è che valorizzeresti $location nel tuo codice?
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  6. #16
    Utente di HTML.it
    Registrato dal
    Feb 2012
    Messaggi
    16
    scusami, nella fretta l'ho dimenticato.
    L'avevo aggiunto qui all'inizio:

    Codice PHP:
    <?php 

    // limit the id lenth to 6 characters... added security.  If you think you'll have more than 999,999 events, you can increase this number. 
    $maxLen 6
    $id substr($_GET['id'],0,$maxLen);
    $location $_GET['location'];

    //Connect To Database 
    include("admin/config.php");
    ma mi restituisce questo:
    Parse error: syntax error, unexpected T_INCLUDE in /home/openopen/public_html/eventi/event2.php on line 28

    Però neanche le altre variabili non sono valorizzate (le date) ...

  7. #17
    E quale sarebbe la riga 28 del codice di grazia?
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  8. #18
    Utente di HTML.it
    Registrato dal
    Feb 2012
    Messaggi
    16
    dimentico che non si da mai niente per scontato, è l'ultima riga del codice nell'ultimo post, dove appunto c'è l'istruzione include:
    Codice PHP:
    <?php  

    // limit the id lenth to 6 characters... added security.  If you think you'll have more than 999,999 events, you can increase this number.  
    $maxLen 6;  
    $id substr($_GET['id'],0,$maxLen); 
    $location $_GET['location']; 

    //Connect To Database  
    include("admin/config.php");

  9. #19
    Utente di HTML.it
    Registrato dal
    Feb 2012
    Messaggi
    16
    ora funziona
    (con $location = $_GET['location'])
    come dicevo, sono alle prime armi

    grazie a tutti per la pazienza!

    ora devo fare in modo che venga selezionato l'evento più recente, ovvero sostituire le date con qcosa tipo "select max(id)" ma stavolta spero di farcela da solo!
    danke!

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.