Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    Nella Guida PHP/MySql pratica, mi da un errore sulla funzione all.php e index.php

    Nella Guida PHP/MySql pratica mi da un errori nelle queste funzione all.php e index.php

    Errore e lo stesso nelle due funzioni:

    Il messagio di errore e questo:
    Parse error: syntax error, unexpected '}', expecting ',' or ';' on line 20

    Il codice e questo


    Codice PHP:
     <?
    include("top_foot.inc.php");
    include(
    "config.inc.php");
    top();

    $db mysql_connect($db_host$db_user$db_password);
    if (
    $db == FALSE)
    die (
    "Errore nella connessione. Verificare i parametri nel file config.inc.php");
    mysql_select_db($db_name$db)
    or die (
    "Errore nella selezione del database. Verificare i parametri nel file config.inc.php");

    if (!isset(
    $start) OR $start<0)
    $start=0;
    $step=20;

    $query "SELECT id,data,titolo FROM news ORDER BY data DESC LIMIT $start,$step";

    $result mysql_query($query$db);
    while (
    $row mysql_fetch_array($result))
    { echo 
    "[url="view.php?id=$row[id]"]" date("j/n/y"$row[data]) . " - $row[titolo][/url]
    ;" 
    }

    <?



    <
    table width=90border=0><tr>
    <
    td width=20align=left>
    ?>

    if ($start>0)
    { $start_back = $start - $step;
    echo "<a href=all.php?start=$start_back>precedenti</a>";
    }
    ?>
    </td>
    <?

    $query 
    "SELECT count(*) AS tot FROM news";

    $result mysql_query($query$db);
    $row mysql_fetch_array($result);

    $pages intval(($row[tot]-1) / $step)+1;

    ?>
    <td width=60% align=center>
    <?
    for ($i=0$i<$pages AND $i<20$i++)
    $start_page $i $step;
    echo 
    "<a href=all.php?start=$start_page>" . ($i+1) . "</a> ";
    }
    ?>
    </td>

    <td width=20%>
    <?
    if ($start $step $row[tot])
    $start_next $start $step;
    echo 
    "<a href=all.php?start=$start_next>successivi</a>";
    }
    ?>
    </td>
    </tr></table>


    <?

    echo "<a href=search.php>Cerca negli articoli</a>";
    foot();
    ?>
    Spero di essermi spiegato bene.

  2. #2
    Utente di HTML.it L'avatar di marco80
    Registrato dal
    May 2005
    Messaggi
    1,357
    Prova cosi':

    Codice PHP:
    <?
    include("top_foot.inc.php");
    include(
    "config.inc.php");
    top();

    $db mysql_connect($db_host$db_user$db_password);
    if (
    $db == FALSE)
    die (
    "Errore nella connessione. Verificare i parametri nel file config.inc.php");
    mysql_select_db($db_name$db)
    or die (
    "Errore nella selezione del database. Verificare i parametri nel file config.inc.php");

    if (!isset(
    $start) OR $start<0)
    $start=0;
    $step=20;

    $query "SELECT id,data,titolo FROM news ORDER BY data DESC LIMIT $start,$step";

    $result mysql_query($query$db);
    while (
    $row mysql_fetch_array($result))
    { echo 
    "<a href=\"view.php?id=".$row[id].">" date("j/n/y"$row[data]) . " - ".$row[titolo]."</a>
    "
    ; }
    ?>




    <table width=90% border=0><tr>
    <td width=20% align=left>
    <?

    if ($start>0)
    $start_back $start $step;
    echo 
    "<a href=all.php?start=$start_back>precedenti</a>";
    }
    ?>
    </td>
    <?

    $query 
    "SELECT count(*) AS tot FROM news";

    $result mysql_query($query$db);
    $row mysql_fetch_array($result);

    $pages intval(($row[tot]-1) / $step)+1;

    ?>
    <td width=60% align=center>
    <?
    for ($i=0$i<$pages AND $i<20$i++)
    $start_page $i $step;
    echo 
    "<a href=all.php?start=$start_page>" . ($i+1) . "</a> ";
    }
    ?>
    </td>

    <td width=20%>
    <?
    if ($start $step $row[tot])
    $start_next $start $step;
    echo 
    "<a href=all.php?start=$start_next>successivi</a>";
    }
    ?>
    </td>
    </tr></table>


    <?

    echo "<a href=search.php>Cerca negli articoli</a>";
    foot();
    ?>
    ho trovato qualcheerrore nella punteggiatura qui in questa parte.

    $result = mysql_query($query, $db);
    while ($row = mysql_fetch_array($result))
    { echo "<a href=\"view.php?id=".$row[id].">" . date("j/n/y", $row[data]) . " - ".$row[titolo]."</a>
    "; }
    ?>

  3. #3
    Lo provato come lo hai fatto te, ma dice lo stesso errore il errore deve essere come dici tu nella punteggiatura.

  4. #4
    Utente di HTML.it L'avatar di marco80
    Registrato dal
    May 2005
    Messaggi
    1,357
    Prova con questa devo aver sbagliato :
    { echo "<a href=view.php?id=".$row[id].">".date("j/n/y", $row[data])." - ".$row[titolo]."</a>
    "; }


    PS scappo dall 'ufficio

  5. #5
    Ok la provo, e grazie per l'aiuto

  6. #6
    Adesso mi da un altro tipo di errore

    Parse error: syntax error, unexpected '<' all.php on line 22

  7. #7
    io ho scritto cosi e mi funziona, anche se io non prendo la data:
    echo "<a href=view.php?id=$row[id]>" . "- $row[titolo]</a>
    ";

  8. #8
    ho iniziato anche io con quella guida, e credimi il solo copiare il codice è inutile, molte cose non le dice e devi metterle tu (ad esempio nella pagina save.php non dice di mettere i $POST e altre cose) cmq è ottimo proprio per questo per imparare ^_^
    Buona fortuna

  9. #9
    Li ho provati tutti, nessuno non funzione strano

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 © 2025 vBulletin Solutions, Inc. All rights reserved.