Welcome to WebmasterWorld Guest from 54.226.146.15

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Confused Need Help

Code using last option only.

     

webgal

2:58 am on May 17, 2007 (gmt 0)

5+ Year Member



Hi All,

I am a newbie and I cannot figure out this problem hopefully someone will be able to assist.

I have:
$query = "update affiliates set StatusId = $row_member_status[0] $row_member_status_iyn[0] where AffiliateId = $row[0]";
$sth=$dbh->prepare($query) or die "Query prep failure.";
$sth->execute() or die "Query execute failure.";
$sth->finish;

I need to tell the script that either
$row_member_status[0]
or
$row_member_status_iyn[0]

but I don't know how to fix that line so that it uses either variable. It just uses the last option:
$row_member_status_iyn[0]

I don't know if this is clear, please let me know if anyone can help.

Just totally confused ;-)

perl_diver

5:28 am on May 17, 2007 (gmt 0)

5+ Year Member



Maybe:


$foo = $row_member_status[0] ¦¦ $row_member_status_iyn[0];
$query = "update affiliates set StatusId = $foo where AffiliateId = $row[0]";

rocknbil

6:55 pm on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You're just saying "either or" - what are the conditions of your "or"?

$foo = ($row_member_status[0]>0)?$row_member_status[0]:$row_member_status_iyn[0];

This says if member_status[0] is greater than zero, use it, otherwise, use $row_member_status_iyn[0]. But this is of no help if $row_member_status_iyn[0] is zero, so . . . what are the conditions? :-)

Drag_Racer

7:08 pm on May 17, 2007 (gmt 0)

5+ Year Member



wouldn't putting the conditional withing ( ) fix it...

$query = "update affiliates set StatusId = ($row_member_status[0] $row_member_status_iyn[0]) where AffiliateId = $row[0]";

perl_diver

10:59 pm on May 17, 2007 (gmt 0)

5+ Year Member



Drag_Racer,

no, parenthesis are just parenthesis inside double-quoted strings, they have no meta meaning.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month