Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Digest Number 374

Expand Messages
  • Charles K. Clarkson
    ... While it is assigned a 0 value, $got is not used in your code. $fr is assigned $ta - $sum, but is also not used, other than in a print statement. It is
    Message 1 of 4 , Jun 2, 2001
      Gordon Stewart <gordonistewart_nz@...> queried:

      : Hi there - its nearly time for bed again, & i'm
      : *ALMOST* there..
      :
      : Ive got the cookies etc.. & the select going -
      : however I think my result ( $got ) is selecting
      : the wrong value.
      :
      : If you want to :-
      :
      : the CGI & full-text are
      :
      : http://n-zealand.hypermart.net/cgi-bin/test/banner3.cgi
      :
      : and
      :
      : http://n-zealand.hypermart.net/cgi-bin/test/banner3.txt
      :
      : I know you can get this down to 10-20 lines or so :-)
      : - not necessary
      :
      : Can anyone point out what i need to change in the
      : small code below
      : (its the segment of code that selects the ad to
      : display.)
      :
      : :- $ta is the random number i've picked (or the
      : computer has picked)
      : :- $got is the value of the 'ad' code thats been
      : selected to display.
      : :- $fr is the pos/negative number (if its positive,
      : then thats the ad to display).

      While it is assigned a 0 value, $got is not used
      in your code. $fr is assigned $ta - $sum, but is also
      not used, other than in a print statement. It is
      never tested. So I assume this part is incomplete.
      Are you trying to pick a random ad or are you trying
      to rotate ads?


      : What i've got is 4 ads - named mab, mac, aad, maa,
      : (in order).
      :
      : Im getting (nothing), mab, mac, aad, but I dont get
      : the 'maa' ad selected.
      :
      : any advise - Im not too familiar wish hashes..
      :
      : G.
      :
      : Partial copy of code follows - The part that displays
      : the 'table' at the bottom of the screen.
      :
      : http://n-zealand.hypermart.net/cgi-bin/test/banner3.cgi
      : ------------
      :
      : # SELECT THE AD TO SHOW #################
      :
      : print "<CENTER><TABLE WIDTH='90%'><TR><TD>AD
      : TYPE<TD>Difference
      : value<TD> <TD> <TD>Sum<TD>Pos/Negative\n";
      : $got=0;
      :
      : $t=0;

      According to the code $dif[0] is never defined,
      $dif[1] and up is.

      : $sum="";
      : $test=0;
      : while ( ($key, $value) = each %list) {

      Unless I missed something, the while can be
      shortened to:

      while (($key, $value) = each %list) {
      next unless $key ne '';

      print "<TR><TD>'$key'<TD>'$value'<TD>'$dif[$t]'<TD>";
      $sum = $sum + $value;
      $fr = $ta - $sum;
      print "<TD>'$sum'<TD>'$fr'<BR>\n";
      $g = $key if $ta > $sum;
      }

      But without knowing the values in %list, I
      don't see why 'maa' is not selected. I think we
      need to see what is in banner.list and a sample
      of what is in the cookies hash.

      [snip]

      HTH,
      Charles K. Clarkson

      :)
      BTW, did you know variable names can be really
      long?

      $selected_ad sure beats $got,
      @time_diff might be better than @dif,
      $index could replace $t,
      a list called %banner_ads could replace
      a list called %list,
      $random_number is more useful than $ta, and


      $x=(time-$tr);
      $list{$testit}=$x;
      $dif[$t]=$x;
      $t=($t+1);

      could be easier to grasp in 3 months as:

      $time_difference = $time_diff[$index++] =
      $banner_ads{$testit} = time - $cookie{testit};

      [one-liners are not necessarily obfuscated]
    • Gordon Stewart
      ... wrote: Gordon Stewart ... ... see why maa is not selected. I think we need to see what is in banner.list and a
      Message 2 of 4 , Jun 3, 2001
        --- "Charles K. Clarkson" <c_clarkson@...>
        wrote: > Gordon Stewart
        <gordonistewart_nz@...>
        > queried:

        > : Ive got the cookies etc.. & the select going -
        > : however I think my result ( $got ) is selecting
        > : the wrong value.

        <CUT>

        > But without knowing the values in %list, I don't
        see why 'maa' is not selected. I think we need to see
        what is in banner.list and a sample of what is in the
        cookies hash.
        <

        When i go to bed (3-4 hours) - I'll upload the
        up-dated script to the online server.

        However if anyones online now - Im on Yahoo Messenger
        ( gordonistewart_nz )

        & they can log-in to my own server to see the updated
        code.

        But my banners list, can be found at :-

        http://n-zealand.hypermart.net/cgi-bin/test/banner.list
        (thats on the web-server - not mine.)

        Basically, there are 4 ads in the list.
        I can 'get' 2-4, but I cannot get no. 1 to be
        'picked'.

        I'm working on the script now (so expect changes)
        - but ive uploaded the new script to :-

        http://n-zealand.hypermart.net/cgi-bin/test/banner.list

        http://n-zealand.hypermart.net/cgi-bin/test/banner3.pl

        http://n-zealand.hypermart.net/cgi-bin/test/banner3.txt

        Gordon - gordonistewart_nz (yahoomessenger)

        thanks.


        =====
        Gordon
        gordon-me@yahoogroups.com (h&w)
        new_zealand-help@yahoogroups.com http://n-zealand.hypermart.net

        ____________________________________________________________
        Do You Yahoo!?
        Get your free @... address at http://mail.yahoo.co.uk
        or your free @... address at http://mail.yahoo.ie
      • Gordon Stewart
        i m also on ICQ - 83440115 - Send a message to me even if it says im offline (im usually pon invisible) - If im online i ll reply woithin 1 min. G.
        Message 3 of 4 , Jun 3, 2001
          i'm also on ICQ - 83440115

          - Send a message to me even if it says im offline (im usually pon
          invisible) - If im online i'll reply woithin 1 min.

          G.
        Your message has been successfully submitted and would be delivered to recipients shortly.