im REALLY sorry...

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

    #1

    im REALLY sorry...

    feel free to slap me in the face on this one... but... i cant figure
    out why this wont work. its acting like its an infinate loop, no
    errors, just wont load. ugh

    <?php
    while (!empty($row_QC BD_test['test'])){
    print $row_QCBD_test['test'];
    }

    ?>

    im a tool.

  • Sergej Andrejev

    #2
    Re: im REALLY sorry...

    meaby becaus it's realy empty =]

    If you still want infinate loop so mutch consider using isset instead
    of empty

    Comment

    • Geoff Berrow

      #3
      Re: im REALLY sorry...

      I noticed that Message-ID:
      <1123143244.367 683.72890@g44g2 000cwa.googlegr oups.com> from kiqyou_vf
      contained the following:
      [color=blue]
      > while (!empty($row_QC BD_test['test'])){
      > print $row_QCBD_test['test'];
      > }[/color]

      You are checking whether $row_QCBD_test['test'] is empty or not.
      Whatever it is, it will still be the same next time round the loop. You
      need something in there to change the state of $row_QCBD_test['test']
      other wise the loop will have no reason to end.

      e.g
      $x=0;
      while($x<10){
      print $x;
      $x++;
      }
      //prints 0123456789
      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Mladen Gogala

        #4
        Re: im REALLY sorry...

        On Thu, 04 Aug 2005 01:14:04 -0700, kiqyou_vf wrote:
        [color=blue]
        > <?php
        > while (!empty($row_QC BD_test['test'])){
        > print $row_QCBD_test['test'];
        > }
        >
        > ?>[/color]

        So, if $row_QCBD_test['test'] is not empty, what should
        prevent the loop from executing ad infinitum? I don't see anything
        to stop it. If nothing stops the loop, the loop will execute
        indefinitely.
        [color=blue]
        >
        > im a tool.[/color]

        I’d rather be a sparrow than a snail
        Yes I would, if I could, I surely would
        I’d rather be a hammer than a nail
        Yes I would, if I only could, I surely would

        --
        大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


        Comment

        • kiqyou_vf

          #5
          Re: im REALLY sorry...

          Ohhhhh, I gotcha I gotcha. Ok, so $row_QCBD_test['test'] is an array
          correct? Can I print out each row in $row_QCBD_test['test'] using a
          while loop? I cant figure out what I'm missing. How about I do
          something like

          while ($rows_returned > 0)
          print $row_QCBD_test['test']

          Would that work?

          I'm going to go play with this thing for the 3rd straight day, thanks
          for your help.

          Comment

          • Geoff Berrow

            #6
            Re: im REALLY sorry...

            I noticed that Message-ID:
            <1123266667.599 271.62670@g49g2 000cwa.googlegr oups.com> from kiqyou_vf
            contained the following:
            [color=blue]
            >Ohhhhh, I gotcha I gotcha. Ok, so $row_QCBD_test['test'] is an array
            >correct? Can I print out each row in $row_QCBD_test['test'] using a
            >while loop? I cant figure out what I'm missing. How about I do
            >something like
            >
            >while ($rows_returned > 0)
            >print $row_QCBD_test['test']
            >
            >Would that work?[/color]

            No. 'While' requires something to change each time round. The bit in
            brackets is a test for truth. In this case it would always be true and
            hence the loop would be infinite.

            I'm assuming you are querying a database? Normally there will be a
            function which returns a new row (and hence true) each time it is
            called. If it were MySQL you'd do something like:

            $sql="SELECT * FROM table";
            $result=mysql_q uery($sql);
            while($myrow=my sql_fetch_array ($result)){
            print $myrow['field1'].",".$myrow['field2']; //etc, etc
            }

            When there are no more rows, mysql_fetch_arr ay($result) returns false
            and the loop stops.

            --
            Geoff Berrow (put thecat out to email)
            It's only Usenet, no one dies.
            My opinions, not the committee's, mine.
            Simple RFDs http://www.ckdog.co.uk/rfdmaker/

            Comment

            • cameron7

              #7
              Re: im REALLY sorry...

              <?
              $row_QCBD_test['test']="Still Not Empty...\n";

              while (!empty($row_QC BD_test['test'])){
              print $row_QCBD_test['test'];
              }
              ?>

              Output:
              -----------------
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              Still Not Empty...
              ad infinitum......

              Comment

              • Mladen Gogala

                #8
                Re: im REALLY sorry...

                On Fri, 05 Aug 2005 11:31:07 -0700, kiqyou_vf wrote:
                [color=blue]
                > while ($rows_returned > 0)
                > print $row_QCBD_test['test'][/color]

                Again, where is the terminating condition? How do you expect
                $rows_returned to eventually drop down to 0 and terminate the loop?
                The loop will continue executing for as long as $rows_returned> 0.
                You haven't done much programming, have you? May be a course
                in programming would be in order? Someone should teach you how
                to write a program. Generally speaking, that's not always simple.

                --
                大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


                Comment

                • Shelly

                  #9
                  Re: im REALLY sorry...


                  "cameron7" <cameron7@gmail .com> wrote in message
                  news:1123294206 .038003.110890@ z14g2000cwz.goo glegroups.com.. .[color=blue]
                  > <?
                  > $row_QCBD_test['test']="Still Not Empty...\n";
                  >
                  > while (!empty($row_QC BD_test['test'])){
                  > print $row_QCBD_test['test'];
                  > }
                  > ?>
                  >
                  > Output:
                  > -----------------
                  > Still Not Empty...[/color]

                  Try:

                  <?
                  $row_QCBD_test['test']="Still Not Empty...\n";

                  while (!$row_QCBD_tes t['test'])){
                  print $row_QCBD_test['test'];
                  $row_QCBD_test = mysql_fetch_ass oc(the_result_v ariable_of_your _query);
                  }

                  Shelly


                  Comment

                  • Shelly

                    #10
                    Re: im REALLY sorry...

                    Correction:

                    "Shelly" <sheldonlg.news @asap-consult.com> wrote in message
                    news:q60Je.2833 $EX.1473@twiste r.nyroc.rr.com. ..[color=blue]
                    >
                    > "cameron7" <cameron7@gmail .com> wrote in message
                    > news:1123294206 .038003.110890@ z14g2000cwz.goo glegroups.com.. .[color=green]
                    >> <?
                    >> $row_QCBD_test['test']="Still Not Empty...\n";
                    >>
                    >> while (!empty($row_QC BD_test['test'])){
                    >> print $row_QCBD_test['test'];
                    >> }
                    >> ?>
                    >>
                    >> Output:
                    >> -----------------
                    >> Still Not Empty...[/color]
                    >
                    > Try:
                    >
                    > <?
                    > $row_QCBD_test['test']="Still Not Empty...\n";
                    >
                    > while (!empty($row_QC BD_test['test'])){
                    > print $row_QCBD_test['test'];
                    > $row_QCBD_test = mysql_fetch_ass oc(the_result_v ariable_of_your _query);
                    > }
                    >
                    > Shelly
                    >[/color]


                    Comment

                    Working...