MyBB Community Forums

Full Version: Using Elseif
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Now I'm not sure if I'm using it right(it's late). Logic wise or correctly for that matter. (Or if it would work)

Right now, my PHP page requires to connect the DB to load. (Not for any content, just some random crap) could i use an else if statement, (like if it doesn't connect to the DB) to just display the static HTML content. Doing it won't be too hard, (Unless I have to include all of that in the statement, would I?)

PHP Newb, so simple terms :p
I don't see why you wouldn't be able to.

http://www.ardamis.com/2008/05/26/a-php-...onnection/

Look like a good example from the viewpoint of another php newb Toungue.
You should be able to use a big if/else just fine Smile

Eg:
<?php
//create db object here ($con)
if ($con) {
//connected to db
} else {
//you aren't connected, so show static HTML
die(); //stop executing the script after displaying the HTML 
}
?>