homepage Welcome to WebmasterWorld Guest from 54.146.175.204
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Confused Need Help
Code using last option only.
webgal

5+ Year Member



 
Msg#: 3341673 posted 2:58 am on May 17, 2007 (gmt 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 ;-)

 

perl_diver

5+ Year Member



 
Msg#: 3341673 posted 5:28 am on May 17, 2007 (gmt 0)

Maybe:


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

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3341673 posted 6:55 pm on May 17, 2007 (gmt 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? :-)

Drag_Racer

5+ Year Member



 
Msg#: 3341673 posted 7:08 pm on May 17, 2007 (gmt 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]";

perl_diver

5+ Year Member



 
Msg#: 3341673 posted 10:59 pm on May 17, 2007 (gmt 0)

Drag_Racer,

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved