This is what the code gives me..........
Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot use a scalar value as an array in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php:49) in /usr/local/apache/htdocs/SimilEbay/vendita_oggetto_descriz.php on line 67

and that's the code

for ($i=0;$i<7;$i++)
{
$sess_checkbox[$i]=$checkbox[$i];
}
session_register(sess_checkbox);

$sess_spesespedizione=$spesespedizione;
session_register(sess_spesespedizione);

$sess_inserire=$inserire;
session_register(sess_inserire);
$sess_spese=$spese;
session_register(sess_spese);

$sess_spedizioneassicurata=$spedizioneassicurata;
session_register(sess_spedizioneassicurata);
$sess_assicurata=$assicurata;
session_register(sess_assicurata);


header("Location:vendita_oggetto_foto.php");
exit();

if i get the seven variable wit simple

$valore=$checkbox[0];
$valore=$checkbox[1];

etc all is ok......but if i try:

for ($i=0;$i<7;$i++)
{
$valore=$checkbox[$i];
//$sess_checkbox[$i]=$checkbox[$i];
}

it gives me an end of execution after 30 seconds.
It's seems....it goes in loop!
why?Someone could help me?

    Hi,

    try to use this:

    for ($i=0;$i<7;$i++) 
       if(isset($checkbox[$i]))
          $sess_checkbox[$i]=$checkbox[$i]; 
       else
          $sess_checkbox[$i]=0;
    

      Ok that's work!Thanx a lot!
      In the while i have used this code to go forward in my coding......

      $sess_checkbox[0]=$checkbox[0];
      $sess_checkbox[1]=$checkbox[1];
      $sess_checkbox[2]=$checkbox[2];
      $sess_checkbox[3]=$checkbox[3];
      $sess_checkbox[4]=$checkbox[4];
      $sess_checkbox[5]=$checkbox[5];
      $sess_checkbox[6]=$checkbox[6];

      and it works!!!it's strange, isn't it?
      it's the same code i have written in a FOR code.........

      but in future if i have to set more variables......is important to know how to code correctly......so thanx for the news....

      But do u know why i have to check if the checkbox[$i] exist?
      In the previous page there were this

      <input type="hidden" name="checkbox[0]" value="<?=$checkbox[0]?>">
      <input type="hidden" name="checkbox[1]" value="<?=$checkbox[1]?>">
      <input type="hidden" name="checkbox[2]" value="<?=$checkbox[2]?>">
      <input type="hidden" name="checkbox[3]" value="<?=$checkbox[3]?>">
      <input type="hidden" name="checkbox[4]" value="<?=$checkbox[4]?>">
      <input type="hidden" name="checkbox[5]" value="<?=$checkbox[5]?>">
      <input type="hidden" name="checkbox[6]" value="<?=$checkbox[6]?>">

      variables passed in the form .............

      Thanx again!

        Because if a
        checkbox is not checked a form don't submit nothing.

        For example:

        <form name="modulo" method=get action="qualchecosa.php">
          <input type="checkbox" name="cb1" value="1"> 
        </form>
        

        When you submit this form you can read in url:

        "qualchecosa.php?cb1=1" if check is checked

        but, if not, just

        "qualchecosa.php?"

        and not

        "qualchecosa.php?cb1=0"

        This tell that if a checkbox is not checked, it is not set. Then refer to any variable (or, worse, any array...) not setted is much dangerous...

        see you

          ok that's right but i have used the hidden values not checkbox!
          And why

          $sess_checkbox[0]=$checkbox[0];
          $sess_checkbox[1]=$checkbox[1];
          $sess_checkbox[2]=$checkbox[2];
          $sess_checkbox[3]=$checkbox[3];
          $sess_checkbox[4]=$checkbox[4];
          $sess_checkbox[5]=$checkbox[5];
          $sess_checkbox[6]=$checkbox[6];
          session_register(sess_checkbox);

          works
          an not in a for cicle?

          for ($i=0;$i<7;$i++)
          {
          $sess_checkbox[$i]=$checkbox[$i];
          }
          session_register(sess_checkbox);

          if the 'for' code is incorrect because the $checkbox[$i] is absent why if i write all seven instruction they work?
          I repeat it's strange!

            but i have used the hidden values not checkbox

            i've looked, but where you get this value="<?=$checkbox[0]?>" ?

            I'm sorry that can't test myself, my php tell me "Undefined offset" in any case. But i think the problem is $checkbox[$i], not for...
            You may try with this, if give error or not:

            $i=0;
            $sess_checkbox[$i]=$checkbox[$i];
            $i++;
            $sess_checkbox[$i]=$checkbox[$i];
            $i++;
            $sess_checkbox[$i]=$checkbox[$i];
            etc...

              i've looked, but where you get this value="<?=$checkbox[0]?>"

              In the 4th page.........there are seven checkbox....because you can go back....i pass them throught <input type="hidden" value=<?=$checkbox[0]?>>
              so if you go forward you have not to select again what you have checked........
              I pass them first in session because all pages go forward to the same page (TO CHECK for incorrect selection) and then redirect to the second with (header("Location:2.php");
              and i won't pass them with header("Location:2.php?variables";
              It's a bit difficult to explain....

              I'm sorry that can't test myself, my php tell me "Undefined >offset" in any case. But i think the problem is $checkbox[$i], not >for...
              You may try with this, if give error or not:

              $i=0;
              $sess_checkbox[$i]=$checkbox[$i];
              $i++;
              $sess_checkbox[$i]=$checkbox[$i];
              $i++;
              $sess_checkbox[$i]=$checkbox[$i];

              I'll try this just now and tell about it!

                Well....
                i have tried

                $i=0;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];
                $i++;
                $sess_checkbox[$i]=$checkbox[$i];

                and it works......
                i have tried again with my for cicle and now it give me no error!!!
                But I'll use your code hope not to encounter again that error when my pages go on line.......
                Thanx a lot!

                  Write a Reply...