Sat, Jul 28, 2012 10:26 pm
Printing Boolean Values as Yes or No
If you have a PHP variable that is storing
for "false" or "no" and
for "true" or
"yes", but want to display the value as "no" when a zero is stored in the
variable and "yes" when a one is stored in the variable, you can print
the value using the ternary operator,
, which is
described in the Ternary Operator
section of the manual page
E.g., suppose I have an array named
swinfo that has
information on various software packages that has an
Free that has a
0 stored in it
if the software is not free and a
1 stored in it if the
software is free. If I have a software package that isn't free, if I just
print the contents of the variable as in the first instance below, I get a
zero, but by using ther ternary operator, i.e., the
?, I can
specify that I want "yes" or "no" displayed, instead as for the
second instance where it is displayed below.
echo "<table>\n" .
$swinfo['Free'] . "</td>" .
($swinfo['Free'] ? 'yes' : 'no') . "</td>" .
For an instance where the software isn't free, I would see the following
Echo boolean field as yes/no or other values
PHP: Hypertext Preprocessor
Sat, Jul 28, 2012 9:12 pm
Printing an array with print_r
The contents of an array can be printed in PHP using
E.g., suppose that the information to be displayed is stored in a database
in a table called
that has student test scores with
each student identified by a student id. The following PHP code could be
used to fetch the test information for a student whose id is stored in the
and then print the entire array named
$result1 = mysql_query("SELECT * FROM tests WHERE ID = $num");
$testinfo = mysql_fetch_array($result1);
Print_r () PHP Function
Sat, Jul 14, 2012 5:17 pm
Attachment and Avatar Settings for SMF 2.0
To modify the attachment and avatar settings of an
Simple Machines Forum (SMF)
forum click on Admin
, then select Forum
then Attachments and Avatars
, and then either Avatar Settings
or Attachment Settings
For the avatar settings, there is an Avatars directory setting
and an Avatars URL setting. If the directory specified for
Avatars directory doesn't exist, then "Avatars directory" is
displayed as red text.
For the attachment settings, you specify an Attachments directory.
If you specify a directory that doesn't exist, the words "Attachments
directory" will be displayed as red text.
If you change any of the settings, click on the
Save button at the bottom of the page to save the new settings.
Sat, Jul 14, 2012 1:11 pm
Deleting a Theme for a SMF 2.0 Forum
To delete a theme for a Simle Machines
2.0 forum, take the following steps from an account with
- Click on Admin then select
Features and Options.
- Click on Configuration then
select Themes and Layout then Theme Settings.
- To the right of each theme listed is an icon
of a piece of paper with a folded corner with a red "X" over it. Click
on that icon to delete the theme.
- You will also need to delete the relevant subdirectory
beneath the SMF Themes directory on the web server where the forum
resides. E.g., for the
Moonlight theme the directory would be Themes/Blue_Moonlight_SMF2.
Mon, Jul 09, 2012 10:16 pm
SMF 2.0 Forum Smileys Location
After I moved a Simple Machines Forum
forum from one domain name to another, I found the smileys, aka
emoticons, were no longer accessible. The steps for pointing the SMF software
to look in a different directory for the smileys is listed below.
- Click on Admin.
- Click on Smileys and Message Icons.
- Click on Settings.
- Change the values for "Base URL to all smiley
sets" and "Absolute path to all smiley sets". Note: If you see "Absolute path
to all smiley sets" as red text, then there is a problem with the path
Sun, Jul 08, 2012 9:14 pm
Comparing Two Directories with Diff
If you need to compare two directories to determine which files are in one
directory, but not another, on a Unix, Linux, or Mac OS X system,
you can use the
command. E.g., suppose the directories
are named dir1 and dir2; they can be compared with
diff dir1 dir2
$ diff dir1 dir2
Only in dir2: index.html
Common subdirectories dir1/temp and dir2/temp
Only in dir2: a.png
Only in dir2: b.png
Only in dir1: 123.png
Only in dir1: 456.png
If you wish to see only the differences and not common directories and
subdirectories, you can use
diff dir1 dir2 | grep "Only".
To perform the comparision recursively through the various subdirectories
within the two directories use
diff --recursive dir1 dir2.
Find files in one directory not in another
Sat, Jul 07, 2012 9:21 pm
Google Member Map 2.6 SMF Mod Installation
I moved a Simple Machines Forum
forum from one domain to another, which required updating
Google Member Map
mod. Google no longer requires a key for using the
map service provided by Google and the latest version of the mod doesn't
even provide a means to specify a key.