Results 1 to 5 of 5

Thread: Can you nest if shorthand? [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    Can you nest if shorthand? [Resolved]

    I tried this and I'm getting a parse error:
    PHP Code:
    <?php 
    if(date(n)<4?1:if(date(n)<7?2:if(date(n)<10?3:4)));?>
    I'm just trying to pick what quarter you're in based on what month it is.
    Last edited by ober0330; Jan 8th, 2004 at 12:26 PM.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    What's the error you do get?
    And what is 'n' ? You do know that variables in PHP start with $, right?

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    the error was a "T_IF" or something error. n is a date notation for the month with no leading zeros... it needs quotations in that piece of code, but I have since put them in and I still get the error.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Can you nest if shorthand?

    Originally posted by ober5861
    I tried this and I'm getting a parse error:
    PHP Code:
    <?php 
    if(date(n)<4?1:if(date(n)<7?2:if(date(n)<10?3:4)));?>
    I'm just trying to pick what quarter you're in based on what month it is.
    PHP Code:
    <?php if(date(n)<4)?1:(if(date(n)<7)?2:(if(date(n)<10)?3:4));?>
    You need to put the brackets in the right place.

    May I also suggest that if you are having trouble finding the error you make the code clearer. IE.
    PHP Code:
    <?php (date (n) < 4) ? : ((date (n) < 7) ? : ((date (n) < 10) ? 4)) ?>
    Last edited by visualAd; Jan 8th, 2004 at 08:32 AM.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Thanks. It's all about the parens.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width