PHP Snippets: Sprintf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The sprintf function provides the same functionality as the printf function, but silently.

This means you would either need to echo the output or concatenate it with a string and echo that string.

$number = 500;
$string = 'miles';

echo sprintf( 'But I would walk %d %s', $number, $string );

PHP Snippets: Printf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The printf function is similar to the echo function in that it will output text, but differs in that it outputs a formatted string.

The syntax of the printf function is:

printf( string, arg 1, arg 2, ... )

Multiple arguments can be provided to the function for each of the placeholders to be replaced.

Continue reading “PHP Snippets: Printf”

Upgrade Fails on Item Master (IV00101)

Microsoft Dynamics GPMost Microsoft Dynamics GP upgrades run through quickly ad without issue but every so often one will encounter a problem. I had one of the upgrades which encountered a problem recently with a client we’d taken over the support from a previous partner.

We always recommend that a test upgrade be done on a standalone server before live to identify exactly this sort of issue. We restored all of the databases onto the new server, installed the client and started the upgrade through GP Utilities; it ran through without issue for a few minutes upgrading several companies before popping up an error window showing there was an issue with the Item Master table:

Company Detail window showing overview of error

Continue reading “Upgrade Fails on Item Master (IV00101)”

PHP Snippets: Quotes

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

Both single and double quotes are supported in PHP, but there is a significant difference in how they are handled.

Single quotes are output “as is” and are the quickest form of quoting. When using single quotes, you would need to concatenate variables with a string to output them:

$fruit = 'apples';

echo 'They drank some juice from ' . $fruit;

Double quotes evaluate variables and many escaped characters. This means you do not need to concatenate variables with the string, but can include them inside the double quoted string:

$fruit = 'apples';

echo "They drank some juice from $fruit";

You can also use curly braces ({} to isolate the variable within the string. When PHP evaluates a string and sees a $ it will take as much of the string as part of the variable name (ending at a space or punctuation), but you can use the curly braces to explicitly set the end of the variable name:

$fruit = 'apple';

echo "They drank some juice from ${fruit}s.";

SQL Snippets: SELECT INTO

Microsoft SQL ServerThis post is part of the series on SQL Snippets.

I occasionally need to make a backup of a SQL table and all rows within; while you can create a table and insert the content, this is the long way of doing. Instead you can use SELECT INTO to both create a table with the correct columns and also to copy the data.

In the below example I am creating a new table suffixed with the date; the first highlighted section is the new destination table to be created and the second the source table:

SELECT *
INTO IV00101_20210910
FROM IV00101

PHP Snippets: Echo

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

Almost everything you write in PHP ill have an output to the user; the simplest way of doing this is to use the in-built echo function (which you can use with or without parentheses).

The below example is a simple echo to output one line of text:

echo 'Hello world!';

You can output multiple lines of text, which you would do with multiple echo function calls:

echo 'Hello world!<br />';
echo 'This is a simple PHP example.';

Notice though, there is a HTML break line tag <br /> included at the end of the first line; if this wasn’t present, then both lines would be output on the same row.

ClassicPress Petitions — Let Your Voice Be Heard

ClassicPressClassicPress started life as a hard-fork of WordPress 4.9; one of the differentiators is the Gutenberg block editor which started by replacing the TinyMCe editor (now generally referred to as the “classic editor”) and is now beig rolled out through other part of a WordPress site.

However, this is just one of the differentiators. One of the largest other differences is the decision making process used by ClassicPress is petition based with the community casting votes instead of a small number of contributors, or even one man, making the decision.

Viktor Nagornyy has a very good write up of the petition process. If you’re a member of the ClassicPress community, or a WordPress user looking for an alternative where you can make a difference, check out the petitions available for voting upon.

Enable Extensions in Vivaldi Private Mode

Vivaldi BrowserI don’t use browser private/incognito modes very often, but sometimes when I do I also want some of the installed Extensions to be available. My browser of choice is Vivaldi and it does allow you to enable extensions, on a per extension basis, in private mode.

To do this, open the Extensions page from the menu or using Ctrl+Shift+E and click the details button on the plugin you want to enable in private mode.

At the bottom of the window which opens, click the Allow in incognito toggle to enable:

Extension's details page

The next private window you open will have the extension enabled.

ClassicPress 1.3.0 Now Available

ClassicPressEarlier this week, the releae of ClassicPress version 1.3.0 was announced; this release focuses on improving accessibility (a11y) which is a key focus for ClassicPress (both the core itself as well as strongly recommending that developers work with accessibility in mind) and one which has a lot of people switching from WordPress as Gutenberg is less accessible that the editor used in ClassicPress.

The ClassicPress blog has details of all the accessibility improvements as well as the new features, minor changes and fixes.

ClassicPress version 1.3.0 has been a while coming, but there are a few core developers now involved and working on new functionality as well as backporting worthy additions from WordPress. There is already planning, and some changes complete, for the 1.4.0 release so it looks like the project is now picking up some speed.

The ClassicPress Plugin Directory is now live and accepting submissions of plugins developed for ClassicPress and also ones developed for WordPress, but which work with ClassicPress. The next stage in the directory will be integration with the ClassicPress admin which is slated for version 2.

There have been one or two wobbles over the last couple of years, global events have very much not helped, but things are looking a lot brighter with more core developers, plugin developers and others all getting involved and helping the project progress.

Microsoft Dynamics GP Reporting Services Reports Not Supported on SQL Express

Microsoft Dynamics GPUsually when installing or upgrading Microsoft Dynamics GP for clients they will use SQL Server Standard and sometimes Enterprise; very rarely, I’ll encounter a mall client who is using or wants to use SQL Server Express.

SQL Server Express is a free version of SQL Server, but which has some limitations. SQL Server Reporting Services (SSRS) is not one of those limitations; you can install SSRS nd it will work happily with SQL Server Express as long as both are installed on the same server.

However, Microsoft Dynamics GP will not deploy reports to SSRS when it is being used with SQL Server Express. if you try you get this error message:

SSRS deployment error

Microsoft Dynamics GP

You do not have security access to the location where you want the reports to be deployed.

You will also be prompted to supply a username and password, but these will never be accepted. The Microsoft Dynamics GP System Requirements say that Dynamics GP will work with Standard, Enterprise and Express editions of SQL Server, but does not mention the limitation of SSRS and SQL Express.

There are some forums posts and such mentioning the restriction, but thought it worth a post as a general reminder.