add an and

Posted on 2009-05-02
Medium Priority
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
  • 2
LVL 39

Expert Comment

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

Open in new window


Author Comment

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

Accepted Solution

Roger Baklund earned 2000 total points
ID: 24286287
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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