add an and

Posted on 2009-05-02
Last Modified: 2012-05-06
hello there,
Im using this to check one database but how can I have (db_site1, db_site2, db_site3)
if($database_rec[0] == 'db_site1') continue;

Open in new window

Question by:XK8ER
    LVL 39

    Expert Comment

    by:Roger Baklund
    Try this:
    if(in_array($database_rec[0],array('db_site1','db_site2','db_site3')) continue;

    Open in new window

    LVL 1

    Author Comment

    I tried this but it didnt work.. is there another way of doing it?
    LVL 39

    Accepted Solution

    Sorry, I mismatched the parantheses, it is missing an ) at the end:
    if(in_array($database_rec[0],array('db_site1','db_site2','db_site3'))) continue;
    # alternative:
    if($database_rec[0] == 'db_site1') continue;
    if($database_rec[0] == 'db_site2') continue;
    if($database_rec[0] == 'db_site3') continue;
    # alternative 2:
    if(($database_rec[0] == 'db_site1') or 
       ($database_rec[0] == 'db_site2') or 
       ($database_rec[0] == 'db_site3')) continue;

    Open in new window


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now