Visualizzazione risultati 1 fino 6 di 6

Discussione: Notice: Use of undefined constant mday

  1. #1
    akis non è connesso Utente giovane
    Data registrazione
    03-03-2010
    Residenza
    Acireale
    Messaggi
    79

    Predefinito Notice: Use of undefined constant mday

    Salve ragazzi,
    vi sottopongo questo problema che non sono riuscito a risolvere....


    Codice PHP:
    if ( ($today["year"] == $dayarray["year"]) && ($today["mon"] == $dayarray["mon"]) && ($today["mday"] == $dayarray["mday"]) ){
    $html_day = $t_day_today;
    $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray[mday]."</a>",$html_day);
    } else {
    * if (
    $calendar_counts[$dayarray[mday]]>0){
    $html_day = $t_day_on;
    $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray[mday]."</a>",$html_day);
    } else {
    $html_day = $t_day_off;
    *
    $html_day = str_replace("<!--day-->",$dayarray[mday],$html_day);
    }
    }
    in questa porzione di codice ho questo messaggio di errore:
    Notice: Use of undefined constant mday - assumed 'mday' in C:\www\blog\lib\html.php on line 171.

    Il problema è che l'errore si ripete decine di volte.... a causa di ciò google non indicizza bene il mio sito. ma l'errore dove sta?


    ho indicato con gli asterischi le righe incriminate che danno errore
    Chi mi aiuta?
    grazie

  2. #2
    L'avatar di dementialsite
    dementialsite non è connesso Super Moderatore
    Data registrazione
    19-10-2004
    Residenza
    fuori Padova
    Messaggi
    5,046

    Predefinito

    Controlla meglio le righe... probabilmente hai dimenticato di scrivere la chiave "mday" tra virgolette.

    Comunque, warning a parte, non dovresti avere problemi di esecuzione: PHP, non trovando una costante chiamata mday, prova a sostituirla proprio con la stringa "mday"...

    Stammi bene...
    Le questioni tecniche hanno risposte migliori nel forum pubblico, non trovi?

    When you don't know your next step... improvise

    ALTERVISTA WANTS YOU!
    Vuoi diventare moderatore su AlterVista? Scopri come...

  3. #3
    akis non è connesso Utente giovane
    Data registrazione
    03-03-2010
    Residenza
    Acireale
    Messaggi
    79

    Predefinito altro errore....

    Citazione Originalmente inviato da dementialsite Visualizza messaggio
    Controlla meglio le righe... probabilmente hai dimenticato di scrivere la chiave "mday" tra virgolette.

    Comunque, warning a parte, non dovresti avere problemi di esecuzione: PHP, non trovando una costante chiamata mday, prova a sostituirla proprio con la stringa "mday"...

    Stammi bene...


    Ciao dementialsite,
    GRAZIE !!effettivamente avevo dimenticato di mettere mday tra virgolette, ed ora moltissimi errori sono spariti.... però è apparto nun nuovo errore....

    Notice: Undefined offset: 1 in C:\www\blog\lib\html.php on line 171

    ... che si ripete fino ad offset: 31.....

    QUESTA E' LA RIGA

    Codice PHP:
    if ($calendar_counts[$dayarray["mday"]]>0){
    $html_day = $t_day_on;
    $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray["mday"]."</a>",$html_day);
    } else {
    $html_day = $t_day_off;
    $html_day = str_replace("<!--day-->",$dayarray["mday"],$html_day);
    }
    Ultima modifica di akis : 17-08-2012 alle ore 14.12.08

  4. #4
    L'avatar di dementialsite
    dementialsite non è connesso Super Moderatore
    Data registrazione
    19-10-2004
    Residenza
    fuori Padova
    Messaggi
    5,046

    Predefinito

    Purtroppo il codice che hai inserito non è sufficiente...

    Posso comunque provare a dirti in cosa consiste l'errore: stai cercando di accedere a una posizione non definita su un array. Prova a ricontrollare in che modo cerchi di scandirne gli elementi (trattandosi di un errore ripetuto, è quasi certamente a monte di un ciclo) e/o in che modo inizializzi l'array, e valuta quali possono essere le correzioni.

    Stammi bene...
    Le questioni tecniche hanno risposte migliori nel forum pubblico, non trovi?

    When you don't know your next step... improvise

    ALTERVISTA WANTS YOU!
    Vuoi diventare moderatore su AlterVista? Scopri come...

  5. #5
    akis non è connesso Utente giovane
    Data registrazione
    03-03-2010
    Residenza
    Acireale
    Messaggi
    79

    Predefinito ecco tutto il codice

    Abbi pazienza....
    questa è la function che genera il calendario nel mio blog..... verifica che ci siano dei post inseriti... nel caso positivo, il giorno in cui è presente il post lo rende linkabile

    Codice PHP:
    function build_calendar($year="",$month="") {

    global
    $theme;

    // validate data
    if ($month==""){
    // if we have no month, make it THIS month
    $month = date("n");
    }

    if (
    $year==""){
    // if we have no year, make it THIS year
    $year = date("Y");
    }

    global
    $monthnames_long;
    global
    $monthnames_short;
    global
    $daynames_long;
    global
    $daynames_short;

    // fill an array with number of entries per day for hilighting purposes
    $con = db_connect();
    $sql = db_sql_calendar_counts($year,$month);
    $result = mysql_query($sql,$con);
    if (
    $result!=false){
    while(
    $row =@ mysql_fetch_array($result)){
    $calendar_counts[$row["nDay"]] = $row["nCount"];
    }
    } else {
    report_problem(1,"<b>build_calendar</b>\n\n".mysql_error()."\n\n".$sql);
    }

    define ('ADAY', (60*60*24));

    // make arrays of values representing the first of the month
    $datearray = getdate(mktime(0,0,0,$month,1,$year));
    $start = mktime(0,0,0,$month,1,$year);

    $firstdayarray = getdate($start);

    // work out the URLs for previous and next buttons
    // default
    $prev_month = $month - 1;
    $prev_year = $year;
    $next_month = $month + 1;
    $next_year = $year;

    // handle exceptions
    // end of year
    if ($month==12) {
    $prev_month = $month - 1;
    $prev_year = $year;
    $next_month = 1;
    $next_year = $year + 1;
    }
    // start of year
    if ($month==1) {
    $prev_month = 12;
    $prev_year = $year - 1;
    $next_month = $month + 1;
    $next_year = $year;
    }
    $url_next = $_SERVER["PHP_SELF"]."?month=".$next_month."&year=".$next_year;
    $url_prev = $_SERVER["PHP_SELF"]."?month=".$prev_month."&year=".$prev_year;


    // get template for entire calendar area
    $html = theme_calendar_section();

    // do the replacements
    $html = str_replace("<!--month_previous_url-->",$url_prev,$html);
    $html = str_replace("<!--month_current_url-->","index.php?year=".$year."&month=".$month,$html);
    $html = str_replace("<!--month_next_url-->",$url_next,$html);

    $html = str_replace("<!--monthname_long-->",$monthnames_long[$datearray["mon"]-1],$html);
    $html = str_replace("<!--year-->",$year,$html);

    // get templates for various squares
    $t_day_heading = theme_calendar_day_heading();
    $t_day_empty = theme_calendar_day_empty();
    $t_day_on = theme_calendar_day_on();
    $t_day_off = theme_calendar_day_off();
    $t_day_today = theme_calendar_day_today();
    $t_calendar_sep = theme_calendar_row_seperator();

    foreach(
    $daynames_short as $day)
    {
    $day_heading = $t_day_heading;
    $day_heading = str_replace("<!--day_heading-->",$day,$day_heading);
    $day_headings .= $day_heading;
    }

    $html = str_replace("<!--day_headings-->",$day_headings,$html);

    // Create the rows of days
    for ($count=1;$count<(6*7+1);$count++){

    $dayarray = getdate($start);

    // new rows on mondays
    if((($count) % 7) == 1) {
    if(
    $dayarray["mon"] != $datearray["mon"]) break;
    $html_days .= $t_calendar_sep;
    }

    if (
    $firstdayarray["wday"]==0) {
    $firstday = 7;
    } else {
    $firstday = $firstdayarray["wday"];
    }

    if(
    $count < $firstday || $dayarray['mon'] != $month) {

    $html_days .= $t_day_empty;

    } else {

    // build the html for a day within the calendar
    $date_url = "index.php?year=".$dayarray["year"]."&month=".$dayarray["mon"]."&day=".$dayarray["mday"];

    $today = getdate();

    // work out if the current day is today
    if ( ($today["year"] == $dayarray["year"]) && ($today["mon"] == $dayarray["mon"]) && ($today["mday"] == $dayarray["mday"]) ){
    $html_day = $t_day_today;
    $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray["mday"]."</a>",$html_day);
    } else {
    if (
    $calendar_counts[$dayarray["mday"]]>0){
    $html_day = $t_day_on;
    $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray["mday"]."</a>",$html_day);
    } else {
    $html_day = $t_day_off;
    $html_day = str_replace("<!--day-->",$dayarray["mday"],$html_day);
    }
    }

    $html_days .= $html_day;

    $start += ADAY;

    // check that day has moved on (to solve the daylight savings problem)
    $testday = getdate($start);
    if (
    $testday["yday"]==$dayarray["yday"]){
    $start += (ADAY/2);
    }
    }
    }

    // put the days into the calendar
    $html = str_replace("<!--calendar_days-->",$html_days,$html);

    db_disconnect($con);

    return
    $html;
    }
    la riga incriminata inizia dopo l'etichetta // work out if the current day is today

    studio da autodidatta php da un paio di anni e le lacune sono tante...... tanto che a me sembra tutto in ordine...... intanto mi dice sempre

    Notice: Undefined offset: 1 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 2 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 3 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 4 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 5 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 6 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 7 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 8 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 9 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 10 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 11 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 12 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 14 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 16 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 18 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 19 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 20 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 21 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 22 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 23 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 24 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 25 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 26 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 27 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 28 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 29 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 30 in C:\www\blog\lib\html.php on line 171

    Notice: Undefined offset: 31 in C:\www\blog\lib\html.php on line 171
    Ultima modifica di akis : 17-08-2012 alle ore 14.37.13

  6. #6
    L'avatar di dementialsite
    dementialsite non è connesso Super Moderatore
    Data registrazione
    19-10-2004
    Residenza
    fuori Padova
    Messaggi
    5,046

    Predefinito

    Credo che l'errore sia quando inizializzi l'array $calendar_counts: probabilmente le chiavi che estrai dal database (con la sintassi $row['nDay']) non sono le stesse che poi vai a cercare usando $dayarray['mday'].

    Puoi averne la conferma se, prima della riga incriminata, inserisci le seguenti righe:
    Codice PHP:
    print_r $calendar_counts;
    echo
    $dayarray['mday'];
    che dovrebbero stamparti le chiavi e i valori di $calendar_counts e il valore di $dayarray['mday'] che vai a cercare tra le chiavi.

    Il punto è: che cosa stai estraendo dal database?

    Stammi bene...
    Le questioni tecniche hanno risposte migliori nel forum pubblico, non trovi?

    When you don't know your next step... improvise

    ALTERVISTA WANTS YOU!
    Vuoi diventare moderatore su AlterVista? Scopri come...

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •