Welcome to WebmasterWorld Guest from 23.20.99.179

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Confused Need Help

Code using last option only.

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

New User

5+ Year Member

joined:May 17, 2007
posts:1
votes: 0


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 ;-)

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

Preferred Member

10+ Year Member

joined:Jan 5, 2006
posts:536
votes: 0


Maybe:


$foo = $row_member_status[0] ¦¦ $row_member_status_iyn[0];
$query = "update affiliates set StatusId = $foo where AffiliateId = $row[0]";
6:55 pm on May 17, 2007 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


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? :-)

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

Full Member

5+ Year Member

joined:Jan 29, 2007
posts:228
votes: 0


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]";

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

Preferred Member

10+ Year Member

joined:Jan 5, 2006
posts:536
votes: 0


Drag_Racer,

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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members