quick php question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    quick php question

    I suck with php. Don't post unless i spent over an hour trying to figure out a simple equation.

    What is the correct way to say this?

    If the item is part1, part2, or the ebay fees are under 25, sig is 0, otherwise sig is 1.

    I tried putting the brackets in different spots with no luck, sig keeps being declared as 0 even though the item is for part1 and the ebay fees are over 25.

    Below is the most recent code I tried.
    Code:
    <?php if ($item->SKU != 'part1' || $item->SKU != 'part2' || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} print $sig ?>
  • lezinterracial
    Confirmed User
    • Jul 2012
    • 3117

    #2
    != means not equal right? and == means equal?

    I'm not good at PHP either.
    Live Sex Shows

    Comment

    • alcstrategy
      Confirmed User
      • May 2012
      • 124

      #3
      Originally posted by mkx
      I suck with php. Don't post unless i spent over an hour trying to figure out a simple equation.

      What is the correct way to say this?

      If the item is part1, part2, or the ebay fees are under 25, sig is 0, otherwise sig is 1.

      I tried putting the brackets in different spots with no luck, sig keeps being declared as 0 even though the item is for part1 and the ebay fees are over 25.

      Below is the most recent code I tried.
      Code:
      <?php if ($item->SKU != 'part1' || $item->SKU != 'part2' || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} print $sig ?>
      why are you using strings for ints like $recipient->ebay_fees < '25' dont use quotations because it is an integer not string. Same thing with the assignments.

      php isnt stricly typed but just for purposes of practice

      if (($item->SKU != 'part1' || $item->SKU != 'part2') || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} should work
      Last edited by alcstrategy; 11-25-2013, 03:58 PM.

      Comment

      • alcstrategy
        Confirmed User
        • May 2012
        • 124

        #4
        also actually the other poster is right != is not equal and == is equals so not sure if it was a typo in your explanation or just wrong coding

        Comment

        • mkx
          Confirmed User
          • Nov 2003
          • 4001

          #5
          Originally posted by alcstrategy
          why are you using strings for ints like $recipient->ebay_fees < '25' dont use quotations because it is an integer not string. Same thing with the assignments.

          php isnt stricly typed but just for purposes of practice

          if (($item->SKU != 'part1' || $item->SKU != 'part2') || $recipient->ebay_fees < '25'){ $sig='0';} else { $sig='1';} should work
          Doesn't seem to work, still makes sig 0.

          if I echo $recipient->ebay_fees it shows a value of 27, thats the way I am pulling it.

          Comment

          • mkx
            Confirmed User
            • Nov 2003
            • 4001

            #6
            I intentionally put does not equal !=

            Comment

            • mkx
              Confirmed User
              • Nov 2003
              • 4001

              #7
              Basically sig should be 1 if any of those 3 criteria are met which 2 of 3 are.

              Comment

              • lezinterracial
                Confirmed User
                • Jul 2012
                • 3117

                #8
                Now, I am no PHP expert but maybe it will make more sense, If you say what the criteria is as opposed to what it isn't

                If I am hearing your right, it should be completely backwards.
                if the item is 1 or the item is 2 or the fee < 25 sig 1, is that correct? If so.

                if (($item->SKU == 'part1' || $item->SKU == 'part2') || $recipient->ebay_fees > '25'){ $sig='1';} else { $sig='0';}
                Last edited by lezinterracial; 11-25-2013, 04:35 PM.
                Live Sex Shows

                Comment

                • EddyTheDog
                  Just Doing My Own Thing
                  • Jan 2011
                  • 25433

                  #9
                  Have you tried using 'Switch-Case' instead?..

                  http://php.net/manual/en/control-structures.switch.php

                  Example:

                  PHP Code:
                  <?php
                  switch($beer)
                  {
                      case 'tuborg';
                      case 'carlsberg';
                      case 'heineken';
                          echo 'Good choice';
                      break;
                      default;
                          echo 'Please make a new selection...';
                      break;
                  }
                  ?>
                  Last edited by EddyTheDog; 11-25-2013, 04:36 PM.

                  Comment

                  • dunhill
                    Confirmed User
                    • Jul 2013
                    • 89

                    #10
                    PHP Code:
                    <?php $sig = ($item->SKU == 'part1' or $item->SKU == 'part2' or $recipient->ebay_fees < 25?0:1)

                    Comment

                    • mkx
                      Confirmed User
                      • Nov 2003
                      • 4001

                      #11
                      Originally posted by dunhill
                      PHP Code:
                      <?php $sig = ($item->SKU == 'part1' or $item->SKU == 'part2' or $recipient->ebay_fees < 25?0:1)

                      Thanks for all the suggestions, this one worked in declaring sig as 1 but if sig is not 1 then it does not declare sig as anything, it should be declared as 0 if not 1, i think I can do this myself though

                      I did the not equals because sometimes there are multiple items and this was my way of troubleshooting it

                      Comment

                      • mkx
                        Confirmed User
                        • Nov 2003
                        • 4001

                        #12
                        Got it all fixed, thanks again!

                        Comment

                        Working...