Insert string into Database as datetime

Inserting values into a database table I wished to add a date and time.

For this I used a convert

CONVERT(datetime, ’26/05/2014 14:21:00′)

However this will fail where the day value is too high. A value greater than 12 will be taken as an invalid month. Also the day and month will be saved swapped.

The date format should be defined as UK based, d/m/y

For this the country format value is included within the conversion.

CONVERT(datetime, ’26/05/2014 14:21:00′, 103)

In this example using 103 to handle UK date format

Note: also ensure there are no spaces at the start or end of  the enclosed string.

Get Table Foreign Key Details by SQL

How to view the foreign key settings within a database administered using MyLittleAdmin?

Looking to find information about foreign keys between tables, via the control panel for a website I was using MyLittleAdmin to manage the associated database.

I was able to view the keys associated with a particular table but unlike the SQL Management Studio this didn’t allow for key review.

I looked to using t-sql and found this

SELECT
  fk.name AS ForeignKey,
  OBJECT_NAME(fk.parent_object_id) AS FkTable,
  COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS FkColumn,
  OBJECT_NAME(fk.referenced_object_id) AS ReferencedTable,
  COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id)
  AS ReferencedColumn,
  delete_referential_action_desc AS OnDelete,
  update_referential_action_desc AS OnUpdate
FROM sys.foreign_keys AS fk
INNER JOIN sys.foreign_key_columns AS fkc
ON fk.object_id = fkc.constraint_object_id
WHERE fk.parent_object_id = OBJECT_ID('OurStuff');

which is taken from https://www.simple-talk.com/sql/t-sql-programming/questions-about-primary-and-foreign-keys-you-were-too-shy-to-ask/

By changing the table reference I was able to get the list of keys and their settings.

Suite CRM Change Initial Quote Number

Using the quotes and invoices within Suite CRM I wished to set an initial number.

The base number was to be a minimum of 4 or 5 digits making the quote, or invoice, number more visible. There’s also the possibility to set the two numbers as a reflection of the year.

Subsequent numbers issued will be incrementally larger.

Searching the Internet I found references to editing the database table values using SQL.

Surely there’s a better way than this! Whilst not averse to such actions I’m aware that updates can potentially over write such amendments.

I also read about changes within the studio admin section, which covers the field types, text values and the like.

Here’s the Studio general view

Suite CRM change initial quote number: Admin Studio

with the more detailed numbers view

Suite CRM change initial quote number: Admin Studio numbers view

Unhappy with both of the above two options I looked for a better solution.

So how did I set the base value for the quote number?

Lets start from the dashboard and select the admin screen.

Suite CRM change initial quote number: select Admin

In the top right hand corner hover over the encircled person icon to show the drop down menu. Select Admin.

Suite CRM change initial quote number: Admin page

On the admin page scroll down to passed the Developer tools section, which includes Studio, which we observed earlier, to the Advanced OpenAdmin. Within this section click on AOS Settings.

Suite CRM change initial quote number: AOS settings

On this page set your base quote number value and if desired one for the invoices.

The number needs to be greater than the current maximum value in the database, as its the highest value from the table which is referenced for the next value.

Don’t forget to click on Save.

Change Colour of Text Underline

Looking to set the underline colour of text to be a different colour to the text.

The default colouring will set the underline colour to be the same as the text, as illustrated below:

Example text with an underlined word

We can use CSS for setting the colour using the parameter will be

text-decoration-color: #dd0000;

This may be included, targeting underlines in general, or by use of classes/ids.

Here’s the same underline, with the text-decoration-color set. In this example I’ve used the in-line style – its easier to use for ad-hoc styling examples.

Example text with an <u style=”text-decoration-color: #dd0000;”>underlined</u> word

Example text with an underlined word

WordPress

Whilst writing this article I noticed that the ready formatting options offered in the WordPress text editor don’t include an underline. Is this for simplicity, rationalising the options available in a limited space, maybe because the underline can so easily be confused with a link, or perhaps use of the tag is no longer encouraged.

I found that version 4.7 of WordPress, from late 2016, removed both the underline and justify options from the TinyMCE editor.

 

 

Windows 10 Manually Checking for Windows Updates

Looking to update Windows 10 manually where can I find the Windows Update page?

Windows 10 Windows update: select settings

From the Windows home screen click on the Windows icon in the bottom left hand corner and then the Settings icon a little above.

Windows 10 Windows update: Windows settings

This view shows the main Windows Settings page. The section of interest is Update & Security, at the bottom. Click on it.

Windows 10 Windows update: Settings Windows update

On the left is a menu of options, including our item of interest, Windows Update, listed at the top. If Windows Update isn’t showing select it from this menu.

Highlighted with a grey background is the manual trigger for the Windows Updates. Click on this to begin a manual check of available updates.

Windows 10 Windows update: check for updates

The page changes to show the update status. Initially a check is made for available updates.

 

An automated WordPress Update has Failed to Complete

Checking a website the morning after a recent WordPress update I found that the update had failed.

At the top of the admin page an error message was showing the message:

An automated WordPress update has failed to complete - please attempt the update again

As per the instruction I clicked on the link to run the update once more.

But that failed too! The message was still showing at the top of the admin screen.

WordPress uses a file in the root of the WordPress installation to determine whether it’s in maintenance mode.

The file named .maintenance is added by the WordPress updater to the root of the WordPress website.

Here’s the scary part. If I delete the file will it cause damage to my WordPress website?

I would allow sufficient time to ensure that WordPress has completed the task which put it into maintenance mode. The update process is reckoned to take not more than 10 minutes, but allow a few more to be sure.

If its an update to the WordPress core files then it will be clear when the task is completed.

As you are searching for reasons for the maintenance mode error message the associated task ought to be complete.

I deleted the file .maintenance from the WordPress root folder.

I clicked on the dashboard link on the admin page, preferring not to click on the update link.

Resolved the failed update notification was gone.

The version of WordPress indicated as installed was the latest one.

DNN Browser Compatibility

Older versions of DotNetNuke supported the configuration of the browser compatibility of a website through the file

/js/ClientAPICaps.config

The operation of the default DotNetNuke SolPart menu with regard to different browsers is governed by this file.

The file is divided into a number of sections, for example:

<functionality nm="DHTML" desc="Dynamic HTML">
  <supports>
    <browser nm="IE" minversion="4" />
    <browser nm="FireFox" minversion="1" />
    <browser nm="Netscape" minversion="5" />
    <browser nm="Gecko" minversion="1" />
    <browser nm="Opera" minversion="7" />
    <browser contains="Iceweasel" />
    <browser contains="Konqueror" />
    <browser contains="Safari" />
    <browser contains="Camino" />
  </supports>
  <excludes>
  </excludes>
</functionality>

In the example given above I have added support for the Konqueror and Iceweasel browsers.

I created an HTML file with the following content to get the details of the browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
  <title>Untitled Page</title>
</head>
<body>
  <script>alert(navigator.userAgent.toLowerCase());</script>
</body>
</html>

I experimented with the browser compatibility options. As mentioned above, adding references for support of lesser used browsers. But found that realistically it added an additional complication to preparing a website. And with websites continually evolving it was going to be an overhead to maintaining websites. After my experimentation I no longer edited the browser configuration, leaving the file as is.

Whilst writing and updating the content of this article I was curious to see whether the file was still included, and if so what it contained. Looking at the latest version on GitHub I found that its content was similar:

<?xml version="1.0" encoding="utf-8" ?>
<capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <functionality nm="DHTML" desc="Dynamic HTML">
    <supports>
      <browser nm="IE" minversion="4" />
      <browser nm="FireFox" minversion="1" />
      <browser nm="Netscape" minversion="5" />
      <browser nm="Gecko" minversion="1" />
      <browser nm="Opera" minversion="7" />
      <browser nm="Mozilla" minversion="1" />
      <browser contains="Konqueror" />
      <browser contains="Safari" />
      <browser contains="Camino" />
      <browser contains="Mozilla" />
    </supports>
    <excludes>
    </excludes>
  </functionality>

Not much has changed with the start of this file over the years.

WordPress Update – 504 Gateway Time-out

Looking to update WordPress to the latest version, I clicked on update, but after a while I received the following error:

504 Gateway Time-out
The server didn't respond in time.

So what to do?

Sometimes with WordPress updates its worth being patient. I’ve seen errors which when returning to the site have cleared. In this case the same was true. I visited the site direct, public view. All was well, but an update was marked as outstanding. It then went to the admin with the WordPress core update pending.

So I refreshed the browser tab with the with the 504 gateway error. And low and behold all was well the update was completed.

One moment of hesitation – a single update was still being shown in the black top bar. But all was well it was a plugin which needed to be updated, based on the newer version of WordPress.

Configure User Agent in FireFox

Setting the browser agent in Firefox allows the browser to pretend to be something else.

Traditionally the user agent string was changed to make the browser appear to be IE6. Without this some websites wouldn’t work.

FireFox hides the User Agent configuration in the about:config settings.

I guess is one of those less frequently configured options – why clutter and confuse the existing configuration options with an item such as this.

To set the user agent string in Firefox. Enter the configuration using about:config in the address bar.

There’s a confirmation that changing the settings can be harmful to the application and that you should only continue if you know what you are doing.

Configure FireFox user agent about:config warning

The configuration parameter to be modified is general.useragent.override. To see if its available enter useragent in the search box.

Its likely that its not listed as a configurable option.

To add it right click in the window (I placed the mouse within the white space below the listing).

On the pop-up menu select New > String

add general.useragent.override as the name of the preference.

The user agent can then be added.

You may prefer to use an Add-On to manage the User Agent. This will allow a list of agents to be maintained with easy switching. Much simpler to checkout websites than to keep returning to the about:config options.

With your FireFox browser configured to allow easy switching off the user agent you are able to test the reason of website to different browsers and bots.

Of particular interest maybe the response of one of your websites to different robots.

One of the website hacks (so called Pharma Hack) is to detect whether the visiting browser is the google-bot or a human visitor. The content of the website is then amended accordingly. If it’s the google-bot then it looks like it’s showing and referencing pharmaceutical products.

Maybe you have configured your website to block the bad robots by their user agent, for example one of the spam bots.

To test whether your website is rejecting these bad bots you can configure Firefox to appear to be one of them by setting the user agent string.

To review and check that your website is presenting itself as you would expect change the user agent in your Firefox browser and visit your website.

DNN 9 Where’s the Allowable File Extensions?

Is the Allowable File Extensions in DNN 9 missing or simply hidden?

The good news is that it’s still available.

The Allowable File Extensions is a list of those file types configured by their file extension which are permitted to be uploaded to the website.

It’s given as a comma separated list within the site’s admin configuration.

Previously it was to be found under the Host > Site Settings page.

DNN 9 Wheres the allowable file extensions? old config option

Looking under the site configuration in DNN 9 I was unable to see the Allowable File Extensions configuration textbox.

It’s still there, but now moved under the Security option.

Begin by selecting the Security menu from the options on the left black panel

DNN 9 Wheres the allowable file extensions? Select security menu

On the security menu select the more tab at the right hand end. Opening this section.

DNN 9 Wheres the allowable file extensions? Security menu

On this tab we have the options for SSL Settings and still More Security Settings. This is the one which we are interested in. Click on it.

DNN 9 Wheres the allowable file extensions? More security settings

Finally we have the page which we are interested in, More Security Settings.

DNN 9 Wheres the allowable file extensions? Security menu more tab

Scroll down the page to the last textbox which shows a list of the different file types which are supported. Add or remove to suit your website requirements.

The Allowable File Extensions isn’t lost/missing. It has been moved under the Security menu section.