GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   quick php question (https://gfy.com/showthread.php?t=1127086)

mkx 11-25-2013 05:44 PM

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 11-25-2013 05:52 PM

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

I'm not good at PHP either.

alcstrategy 11-25-2013 05:56 PM

Quote:

Originally Posted by mkx (Post 19885758)
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

alcstrategy 11-25-2013 06:02 PM

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

mkx 11-25-2013 06:15 PM

Quote:

Originally Posted by alcstrategy (Post 19885780)
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.

mkx 11-25-2013 06:17 PM

I intentionally put does not equal !=

mkx 11-25-2013 06:18 PM

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

lezinterracial 11-25-2013 06:33 PM

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';}

EddyTheDog 11-25-2013 06:33 PM

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;
}
?>


dunhill 11-25-2013 06:35 PM

PHP Code:

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


mkx 11-25-2013 06:43 PM

Quote:

Originally Posted by dunhill (Post 19885857)
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

mkx 11-25-2013 06:50 PM

Got it all fixed, thanks again!


All times are GMT -7. The time now is 11:04 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123