Fri, Aug 04, 2017 10:51 pm

I have an SQLite database
that I use to track work requests. Some requests are time sensitive, i.e. they
need to be completed within a certain number of days from the time they are
approved. So I have an "Approved" and an "Implemented"
column in the
database to record the date I approved a request and the date it was
implemented. All requests should be completed within 5 business days, so
when I display the data on a webpage with
PHP, I want to see the
number of elapsed working days between the time I approved a request and the
time it was implemented. To do so, I use some code provided by George John
at
Calculate business days with a slight modification. The code I use appears
below:

Mon, Jul 03, 2017 10:03 pm

I have a PHP
script that queries an SQLite database displaying the results on a web page.
There are two fields, "EC Link" and "Configs Link" in the database that can
contain URLs
pointing to documentation on another server, but sometimes there is no URL in
the database for those fields. If there is a URL, I want to display a clickable
"EC" and "Configs" links. If there is no URL in either field, I want to
simply display the text, but without it being clickable to indicate that there
is no URL in the database table. I was using "is_null" for that purpose as
shown below:

But I found that sometimes I was seeing clickable links even though there
was no URL for the EC and/or Configs documentation for a particular
record in the database. When I checked the records in the relevant
table in the database, I found that the fields were blank, i.e., there
was no data in them, but they weren't marked as
null.
So, to allow for the values being either null or blank, I used an
empty, instead of is_null, test.

Mon, Sep 26, 2016 10:51 pm

To query a
MariaDB - MariaDB is a
fork of
MySQL -
database using PHP, code similar to that shown below can be used.
In this exmple, the account used to query the database is johndoe
with a password of ThePassword. The database is named
Acme and contains a table named Accounts.

Sun, Jun 05, 2016 11:02 pm

If you need to verify the PHP code in a .php file, you can do so from a
command line interface (CLI), e.g., a
shell
prompt using the -l option; that's the letter "l", not the
number "1". E.g., when I tried accessing a web page I had created,
e.g., http://www.example.com/sompepage.php, I saw only a blank page. If
I examined the source code for the page in the browser from which I was
viewing the page, there was nothing there. Looking through the PHP code,
the cause of the error wasn't immediately obvious to me, but when I
issued the command php -l somepage.php on the server where
the page resided, the line that was causing the problem was identified.

Examining the code, I realized I had omitted a required semicolon from the
prior line. When I added the semicolon at the end of the line and reran the
check, I no longer saw any error messages and when I refreshed the webpage in
the browser after making the update, it then displayed correctly.

Sat, Mar 12, 2016 5:24 pm

I wanted to determine the user name under which PHP was running for a
WordPress blog on a hosting site. To do so, I placed a PHP script,
whoami_here.php, in the home folder for the WordPress installation
and then accessed the webpage for that script via a browser, e.g.
http://example.com/whoami_here.php.

There are a variety of methods you can use to check on which account
PHP is running under, e.g., <?php passthru("whoami"); ?>,
though some methods may not work on some systems.

I verified the time zone was set correctly at the operating system level
with the timedatectl
command, so I realized the issue must be with PHP itself. I checked the
location of the PHP configuration file, php.ini and found it was
located at /etc/php.ini.

Sat, Jul 28, 2012 10:26 pm

If you have a PHP variable that is storing
Boolean data,
i.e. 0 for "false" or "no" and 1 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
Comparison Operators.

E.g., suppose I have an array named swinfo that has
information on various software packages that has an
array variable 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.

Sat, Jul 28, 2012 9:12 pm

The contents of an array can be printed in PHP using print_r.
E.g., suppose that the information to be displayed is stored in a database
in a table called tests 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
variable $num and then print the entire array named
testinfo.

Sun, Feb 13, 2011 10:34 pm

I wanted to run PHP for some virtual hosts on a webserver using the
user's account for her websites that were handled in Apache's
httpd.conf via virtual hosts. To do so, I used
use suEXEC, but
it took me quite awhile to get it to work..