Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-25-2013, 05:44 PM   #1
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
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 ?>
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 05:52 PM   #2
lezinterracial
Confirmed User
 
Industry Role:
Join Date: Jul 2012
Posts: 3,073
!= means not equal right? and == means equal?

I'm not good at PHP either.
__________________
Live Sex Shows
lezinterracial is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 05:56 PM   #3
alcstrategy
Confirmed User
 
Industry Role:
Join Date: May 2012
Posts: 124
Quote:
Originally Posted by mkx View Post
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 at 05:58 PM..
alcstrategy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:02 PM   #4
alcstrategy
Confirmed User
 
Industry Role:
Join Date: May 2012
Posts: 124
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
alcstrategy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:15 PM   #5
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by alcstrategy View Post
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:17 PM   #6
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
I intentionally put does not equal !=
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:18 PM   #7
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Basically sig should be 1 if any of those 3 criteria are met which 2 of 3 are.
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:33 PM   #8
lezinterracial
Confirmed User
 
Industry Role:
Join Date: Jul 2012
Posts: 3,073
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';}
__________________
Live Sex Shows

Last edited by lezinterracial; 11-25-2013 at 06:35 PM..
lezinterracial is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:33 PM   #9
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,044
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 at 06:36 PM..
EddyTheDog is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:35 PM   #10
dunhill
Confirmed User
 
dunhill's Avatar
 
Industry Role:
Join Date: Jul 2013
Posts: 89
PHP Code:
<?php $sig = ($item->SKU == 'part1' or $item->SKU == 'part2' or $recipient->ebay_fees 25?0:1)
dunhill is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:43 PM   #11
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by dunhill View Post
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-25-2013, 06:50 PM   #12
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Got it all fixed, thanks again!
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.