wpdb – Check if Value Exists in Database, adding row details to variables and echoing result

I am trying to create a UK Postcode checker for a clients Woocommerce shop. I have created a table in WordPress with the cells, Postcode, Town and County.

When a user enters their postcode into a form and clicks submit, I want to check if the postcode exists in our database, and let the user know.

My code is not recognising whether the postcode exists in the database or outputting the town later.

Any help would be most gratefully appreciated.

global $wpdb;
$table_name = $wpdb->prefix.'vw_postcode_checker';

if (!empty($_POST(postcode)))
    $postcode = $_POST(postcode);
    $entry = $wpdb->get_results("SELECT * FROM ".$tablename."WHERE postcode =" . $postcode);
    if(count($entry) == 1){
         $id = $entry->id;   //We need this for the delete to work.
         $postcode = $entry->postcode;
         $town = $entry->town;
         $county = $entry->county;
         $confirmed = "Contratulations, we are delivering to" . $town;
         echo $confirmed;
    else {
    $notconfirmed = "Sorry, we are not delivering to your area at this time.";
    echo $notconfirmed;

8 – How to get drupal to check for a twig template in the active theme folder before checking the module folder?

I’m developing a contrib module for Drupal 8 that sends email notifications to group members when new content has been posted in groups they have subscribed to. The module defines some new view modes for nodes and comments. It then uses these new view modes to render the contents of the emails it sends out. The module defines a theme hook suggestion for each view mode and supplies a twig template for each view mode.

It works fine as is. The twig templates from within the module are utilized without a problem. What I’m not understanding is why copies of these templates placed within the active theme are not utilized. I’m familiar with the process of copying an existing twig template into a theme to be modified. But no matter what I do the template from the module is always used in this case. It was my understanding Drupal searches for suitable twig templates in the theme first and then works backward but perhaps my module is missing something.

Here are code samples for more details.

Define the view mode for comments – in modules/contrib/group_subscription/config/install/core.entity_view_mode.comment.group_subscription_immediate

langcode: en
status: true
    - comment
id: comment.group_subscription_immediate
label: 'Group Subscription Immediate (comment)'
targetEntityType: comment
cache: true

Define the theme hook suggestion – in modules/contrib/group_subscription/group_subscription.module

 * Implements hook_theme()
function group_subscription_theme($existing, $type, $theme, $path) {
  return (
    'comment__group_subscription_immediate' => (
      'base hook' => 'comment',

 * Implements hook_theme_suggestions_comment_alter()
function group_subscription_theme_suggestions_comment_alter(array &$suggestions, array $variables) {
  if ($variables('elements')('#view_mode') == 'group_subscription_immediate') {
    $suggestions() = 'comment__group_subscription_immediate';

Please let me know if there is anything else I can provide to help me figure this out. I’ve been working with Drupal for years but am still relatively new to D8 and this is my first attempt at creating a module to give back. Thanks in advance!

ubuntu 16.04 – How to check what users can possibly access and control my server?

I have recently got access to a legacy server previously manage by someone else.
Access control and password changing is the priority by now.
I have some shell base knowledge but definitely not a senior sysadmin. And need some guidance and general suggestion about his topic.

So I have root access and I can check the list of users.

I wonder if there’s a way to understand immediately from /etc/passwd contents what are the unix user that could possibly access the system, filtering out the standard user.
System is Ubuntu 16

And I can see from passwd that root is the only user having “/bin/bash”:


Other users seems more related to installed services..
So maybe no other users apart root were used before to access the system
Is there a way to check it?

I’m supposing that all users having the last row token like:

:[void no chars]

should be system’s service users

Aren’t they?

Thanks for any advice

check if one expression can be transformed into another

My question is how to use Mathematica to check if one expression can be transformed into another:

Example 1:
$ax^2+bx+c$ into $Kcdot(x+alpha)^2+beta$, and then show me $K(a,b,c)$ and so on.

Example 2:
Say I have the Maxwell equations:

$nabla cdot mathbf{E} = frac{rho}{varepsilon_0}$, $nabla times mathbf{E} = -dot {mathbf{B}}$, $nabla cdot mathbf{B} = 0$, $nabla times mathbf{B} = mu_0 (varepsilon_0 mathbf{j} + dot{mathbf{E}})$.

Can I follow from this an expression of the form $alpha ddot {mathbf{E}}+beta mathbf{E}=0$?

Example 3:
$c_1 cos(omega t) + c_2 sin(omega t)$ into $A cos (omega t + delta)$. How do I mark the dependencies, so that $A$ is $A(c_1, c_2)$ but not $A(t)$?

Check out my tech site


y u no do it?

Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just $1 per CPM or $0.10 per CPC.

8 – How to check if custom variation field is null in twig?

I would like to know how to check if a custom variation field has content in a twig template (commerce-product.html.twig with variations injected). I have tried with some filters and conditions but without success. I need to hide some html markup if the field is empty. For example:

{% if product.variation_field_mycustomfield is not empty %}
<div class="mycustomclass">My custom field: {{ product.variation_field_mycustomfield }}</div>
{% endif %}  

My products have some variations that users can select from a list. When this select changes, the product information must change, and some variations of the same product could have this field empty or not.

orthogonality – Check if the system: $sin left(frac{2pi n x}{b-a} right), cos left(frac{2pi n x}{b-a} right)$is orthogonaloover the interval [a=12, b=14].

My work thus far:
$$int^{14}_{12} sinleft(frac{2pi n x}{14}right) cosleft(frac{2pi n x}{14}right)dx = \int^{14}_{12} frac{1}{2}sinleft(frac{2pi n x}{7}right)dx = frac{7}{4n}pi left(-cosleft(frac{2pi n x}{7}right) right)^{14}_{12} = frac{7}{4n}pi left(-cosleft(4pi nright) +cosleft(frac{12pi n}{7}right) right) $$

I don’t know how to proceed to show that it is not equal to zero. Is it as simple as just writing $4pi n neq frac{12 pi n}{7}$ or is there some catch?