Begging PHP, length of message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerry N

    Begging PHP, length of message

    My guestbook brekas down if the message is to long. The method is
    POST, can it still be limits in the length of the message?

    Gerry

    The code:

    <?php
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");

    ?>
    <p><pre>

    </pre>



    <form method="post" action="store.p hp3">

    <span class="text"> Meddelande:</span><br>
    <TextArea name="meddel" rows=5 cols=50></TextArea><br>
    <span class="text"> Namn:</span><br>
    <input type="Text" name="namn"></input><br>

    <input type="Submit" name="submit" value="Skicka"> </input>
    </form>

    <?
    // ------ Editera dessa! --------------
    $persida=10; // Antal inlägg som skall visas per sida.
    $noprev="noprev .gif"; // Sökväk till deaktiverad föregångar-knapp.
    $nonext="nonext .gif"; // Sökväg till deaktiverad nästa-knapp.
    $prev="prev.gif "; // Sökväg till föregångar-knapp.
    $next="next.gif "; // Sökväg till nästa-knapp.
    // ------------------------------------

    $sidor=0;
    $storlek=0;
    $namn="";
    $epost="";
    $meddelande="";
    $titel="";
    $hemsida="";
    $sidnr=1;

    $ipnr="";
    $tidp="";
    $datum="";

    function initiera(){
    // Initiering av de komponenter som behövs. Körs alltid först!

    global $sidor, $persida, $namn, $epost, $meddelande, $hemsida, $titel,
    $storlek, $start, $sidnr,

    $ipnr, $tidp, $datum;


    // Läs i fil antalet inlägg i gästboken
    if(!($fpread = fopen("inlagg.t xt", 'r'))){
    $fpwrite = fopen("inlagg.t xt", 'w');
    fputs($fpwrite, "0\n");
    fclose($fpwrite );
    $sidor=1;
    $storlek=0;
    }else{
    $storlek=fgets( $fpread,1024);
    $sidnr=floor($s tart/$persida)+1;
    // Beräkna hur många sidor dessa inlägg tar
    $sidor=ceil($st orlek/$persida);
    if($sidor==0) $sidor=1;
    // Läser igenom dagboksfil en och lagrar inlägg som skall visas på
    denna sida
    $mess=0;
    $index=0;
    while(!feof($fp read)){
    $data1=fgets($f pread,200);
    $data2=fgets($f pread,200);
    $data3=fgets($f pread,200);
    $data4=fgets($f pread,200);
    $data5=fgets($f pread,2020);
    $data6=fgets($f pread,1024);
    $tom=fgets($fpr ead,1024);
    if($mess>=$star t && $mess<$start+$p ersida){
    $namn[$index]=$data1;
    $epost[$index]=$data2;
    $hemsida[$index]=$data3;
    $titel[$index]=$data4;
    $meddelande[$index]=$data5;
    list($ipnr[$index],$datum[$index],$a,$b,$c)=expl ode(":",$data6) ;
    $tidp[$index]="$a:$b";

    $index=$index+1 ;
    }
    $mess++;
    }
    }
    }
    function visa_nav(){
    global $start,$persida ,$storlek,$sido r,$sidnr;

    echo "::: ";
    for($i=1;$i<=$s idor;$i++)
    if($i==$sidnr)
    echo "<a href=\"$PHP_SEL F?start=".($i-1)*$persida."\" ><b>$i</b></a>
    ::: ";
    else
    echo "<a href=\"$PHP_SEL F?start=".($i-1)*$persida."\" >$i</a> ::: ";
    }
    function visa_nav_framat (){
    // Visar navigeringsknap p för "nästa"
    global $start, $sidor, $persida, $storlek;
    global $next, $nonext;
    if($start+$pers ida<$storlek){
    $newpage=$start +$persida;
    echo "<a href=\"$PHP_SEL F?start=$newpag e\"><img src=\"".$next." \"
    border=\"0\"></a>";
    }else{
    echo "<img src=\"".$nonext ."\">";
    }
    }
    function visa_nav_bakat( ){
    // Visar navigeringsknap p för "föregående "
    global $start, $sidor, $persida, $storlek;
    global $prev, $noprev;

    if($start>=$per sida){
    $newpage=$start-$persida;
    echo "<a href=\"$PHP_SEL F?start=$newpag e\"><img src=\"".$prev." \"
    border=\"0\"></a>";
    }else{
    echo "<img src=\"".$noprev ."\">";
    }
    }
    function visa_antal_medd elanden(){
    global $storlek;
    echo $storlek;
    }
    function visa_antal_sido r(){
    global $sidor;
    echo $sidor;
    }
    function visa_sidnr(){
    global $sidnr;
    echo $sidnr;
    }
    function visa_meddelande ($index){
    global $namn, $epost, $meddelande, $hemsida, $titel, $start, $storlek,
    $persida, $sidor, $ipnr,

    $tidp, $datum;
    $sidan=floor($s tart/$persida)+1;
    $limit=$persida ;
    if(($sidan==$si dor) && ($storlek % $persida)>0)
    $limit=$storlek %$persida;
    if($index<$limi t && $storlek>0){
    //////////////////////////////////////////////////////////////

    echo "

    Datum: <i>$datum[$index]</i> Klockan <i>$tidp[$index]</i><br>

    Namn: <b>$namn[$index]</b></font><br>

    <font color='black'>$ meddelande[$index]</font><br><br><h r>
    ";
    ///////////////////////////////////////////////////////////////
    }
    }
    ?>


    <! ----------------------------------------------- !>

    <html>
    <head>
    <title>Bilder </title>
    </head>


    <! Utför initiera först !>
    <?initiera(); ?>

    <center>


    <br>
    <?visa_nav();?> <br>
    Det finns <?visa_antal_me ddelanden();?> meddelanden på
    <?visa_antal_si dor();?> sidor. Detta är

    sida <?visa_sidnr(); ?>.
    </center>
    <br>

    <hr>

    <! Visa alla inläggen på sidan !>
    <?
    for($i=0;$i<=$p ersida;$i++)
    visa_meddelande ($i);
    ?>

    <tr>
    <td>


    </body>
    </html>

  • Shawn Wilson

    #2
    Re: Begging PHP, length of message

    Gerry N wrote:[color=blue]
    >
    > My guestbook brekas down if the message is to long. The method is
    > POST, can it still be limits in the length of the message?[/color]

    There are limits to the amount of text that can go in form elements, depending
    on the browser. What browser are you using to test and how long is too long?
    You might want to start by determining the exact character length, if it's
    constant.

    You might also want to try tracking down the error by printing the value at
    different points in the script. Usually, you won't get a good response in this
    group if you post an entire script, especially if it's in a language other than
    English. Most people here like to look at small snippets of code and only the
    code where you believe the error to be originating.

    Regards,
    Shawn
    --
    Shawn Wilson
    shawn@glassgian t.com


    I have a spam filter. Please include "PHP" in the
    subject line to ensure I'll get your message.

    Comment

    • Gerry N

      #3
      Re: Begging PHP, length of message

      On Thu, 15 Jan 2004 10:11:16 -0400, Shawn Wilson
      <shawn@glassgia nt.com> wrote:
      [color=blue]
      >Gerry N wrote:[color=green]
      >>
      >> My guestbook brekas down if the message is to long. The method is
      >> POST, can it still be limits in the length of the message?[/color]
      >
      >There are limits to the amount of text that can go in form elements, depending
      >on the browser. What browser are you using to test and how long is too long?
      >You might want to start by determining the exact character length, if it's
      >constant.
      >
      >You might also want to try tracking down the error by printing the value at
      >different points in the script. Usually, you won't get a good response in this
      >group if you post an entire script, especially if it's in a language other than
      >English. Most people here like to look at small snippets of code and only the
      >code where you believe the error to be originating.
      >
      >Regards,
      >Shawn[/color]

      Toio long is maybe a bit less than an A4 full written. The browser is
      IE 6, it doesn't seem important to the problem as it occur in all
      browsers.
      A snippet af the code that I as a beginner in this, coluld suspect
      some problem is here:

      $mess=0;
      $index=0;
      while(!feof($fp read)){
      $data1=fgets($f pread,200);
      $data2=fgets($f pread,200);
      $data3=fgets($f pread,200);
      $data4=fgets($f pread,200);
      $data5=fgets($f pread,2020);
      $data6=fgets($f pread,1024);
      $tom=fgets($fpr ead,1024);
      if($mess>=$star t && $mess<$start+$p ersida){
      $namn[$index]=$data1;
      $epost[$index]=$data2;
      $hemsida[$index]=$data3;
      $titel[$index]=$data4;
      $meddelande[$index]=$data5;
      list($ipnr[$index],$datum[$index],$a,$b,$c)=expl ode(":",$data6) ;
      $tidp[$index]="$a:$b";

      Any clue?

      Gerry

      Comment

      • Shawn Wilson

        #4
        Re: Begging PHP, length of message

        Gerry N wrote:[color=blue]
        >
        > On Thu, 15 Jan 2004 10:11:16 -0400, Shawn Wilson
        > <shawn@glassgia nt.com> wrote:
        >[color=green]
        > >Gerry N wrote:[color=darkred]
        > >>
        > >> My guestbook brekas down if the message is to long. The method is
        > >> POST, can it still be limits in the length of the message?[/color]
        > >
        > >There are limits to the amount of text that can go in form elements, depending
        > >on the browser. What browser are you using to test and how long is too long?
        > >You might want to start by determining the exact character length, if it's
        > >constant.
        > >
        > >You might also want to try tracking down the error by printing the value at
        > >different points in the script. Usually, you won't get a good response in this
        > >group if you post an entire script, especially if it's in a language other than
        > >English. Most people here like to look at small snippets of code and only the
        > >code where you believe the error to be originating.
        > >
        > >Regards,
        > >Shawn[/color]
        >
        > Toio long is maybe a bit less than an A4 full written. The browser is
        > IE 6, it doesn't seem important to the problem as it occur in all
        > browsers.
        > A snippet af the code that I as a beginner in this, coluld suspect
        > some problem is here:[/color]
        <SNIP>[color=blue]
        >
        > Any clue?[/color]

        I find that code really hard to read. My best guess (without reading the code
        line by line) is that it's cutting off after a newline of after the 1024 bytes
        mentioned in the fgets. I would count the characters (actually, just use strlen
        instead of counting). See if the length conforms to the 1024 or 2020
        characters. Also, does it always end on a newline or will it cut off mid-word?

        Answering those questions might give you a clue.

        Is the whole entry being written to the text file?

        Could you give an example of the text file you're storing the text in?

        Regards,
        Shawn
        --
        Shawn Wilson
        shawn@glassgian t.com


        I have a spam filter. Please include "PHP" in the
        subject line to ensure I'll get your message.

        Comment

        • Gerry N

          #5
          Re: Begging PHP, length of message

          [color=blue][color=green]
          >>
          >> Any clue?[/color]
          >
          >I find that code really hard to read. My best guess (without reading the code
          >line by line) is that it's cutting off after a newline of after the 1024 bytes
          >mentioned in the fgets. I would count the characters (actually, just use strlen
          >instead of counting). See if the length conforms to the 1024 or 2020
          >characters. Also, does it always end on a newline or will it cut off mid-word?
          >
          >Answering those questions might give you a clue.
          >
          >Is the whole entry being written to the text file?
          >
          >Could you give an example of the text file you're storing the text in?
          >[/color]

          Changing the 1024 doesn't make any different but the changing of the
          2020 number did the job. Though, where does the 2020 come from???
          Doesn't seem to fit in the digital world!?

          Gerry

          Comment

          • Shawn Wilson

            #6
            Re: Begging PHP, length of message

            Gerry N wrote:[color=blue]
            >[color=green][color=darkred]
            > >>
            > >> Any clue?[/color]
            > >
            > >I find that code really hard to read. My best guess (without reading the code
            > >line by line) is that it's cutting off after a newline of after the 1024 bytes
            > >mentioned in the fgets. I would count the characters (actually, just use strlen
            > >instead of counting). See if the length conforms to the 1024 or 2020
            > >characters. Also, does it always end on a newline or will it cut off mid-word?
            > >
            > >Answering those questions might give you a clue.
            > >
            > >Is the whole entry being written to the text file?
            > >
            > >Could you give an example of the text file you're storing the text in?
            > >[/color]
            >
            > Changing the 1024 doesn't make any different but the changing of the
            > 2020 number did the job. Though, where does the 2020 come from???
            > Doesn't seem to fit in the digital world!?[/color]

            It is an strange number. I don't know why they would have chosen it.

            Regards,
            Shawn
            --
            Shawn Wilson
            shawn@glassgian t.com


            I have a spam filter. Please include "PHP" in the
            subject line to ensure I'll get your message.

            Comment

            Working...