node.js – Handles non-MySQL errors that are thrown

I was trying to query MySQL DB, using mysql module, inside NodeJS when I entered this error. I tried to catch it using the try-catch function, but somehow it doesn't work and my app still crashed. I got this when I tried to insert null into non-null field.

try {
    let query = /* ... */
    connection.query(query, (err, result) => {
        if (err) res.status(400).send({ code: 400 })
        res.status(200).send({ code: 200 })
    }) 
} catch(e) {
     console.log(e)
}

Error:

throw err; // Rethrow non-MySQL errors
      ^

Error (ERR_HTTP_HEADERS_SENT): Cannot set headers after they are sent to the client

Where should I catch this error, if it's not in the exact place where I run my query?
Any help could be appreciated. Thank you.

Keep getting 404 errors in WHT

WHT has been virtually unusable for the past 24 hours.

I keep getting "Server is busy" and an "404" error message on my pages …

********** … | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1803950&goto=newpost

errors – How to validate a password protected page

For some unknown reason to me (I am not the original developer). This custom WordPress site does not display the password protected login form … "This content is password protected! To view it, please enter your password below:".

The page shows that it is protected, but visitors can still see the entire page. I manage to use the code that works that activates the form and blocks access. The login works fine and the wrong password does not allow access to the page. This is good. It just doesn't show an error message.

Does anyone know how to display an error message or even a class so I can enter an error message when sending the wrong password?


This content is password protected. To view it please enter your password below:


// echo out all of the post content

c – Change the box with while / if inside it causing errors

I am working on a program that performs a debit transaction through buttons like keys. So far, I have been able to get the default "Hello" message to be displayed from the beginning until button 1 or button 2 (PB1 and PB2) is pressed. It seems I have a problem with my change statement. This is what I am trying to do: initialize with "Hello" on the screen and wait for the user to press a button. If PB1 is pressed, go to case 2. Within case 2, it will display a total amount and ask the user to press PB1 to accept or PB2 to cancel. If PB1 was pressed, go to case 3. If PB2 was pressed, go back to case 1 and resubmit the default message until the user presses a button. Case 3 will only determine what account they take and will go to Case 4 to accept a PIN # (I didn't include this, but this is essentially the process I'm trying to complete).

Push button states are like & # 39; 1 & # 39; as long as they are NOT pressed, and when they are pressed they are & # 39; 0 & # 39 ;. This is why I have tried using while (PB1 == 0), so if PB1 is pressed, do the following. I've also tried using if (PB1 == 0) to do the same thing, but it seems to get me stuck in a loop of just printing hello over and over in both cases. Then, while I'm in this cycle, if I press PB1 it immediately moves to "Total is $ 20.75
Press 1 for OK or 2 for CANCEL "to" Canceled ", at which point simply repeat" Canceled "instead of going back to Case 1." Canceled "should only print if PB2 is pressed, which is not what I have done yet, but still prints.

Any help would be highly appreciated.

int beginProcess = 1;


  while (1)
  {

      switch (beginProcess)
      {

          case 1:
            printf("Hello rn");
            PB1 = readPin1;

            while (PB1 == 0)
            {
                beginProcess = 2;
            }
            break;

          case 2:
              printf("Total is $20.75 rn");
              printf("Press 1 for OK or 2 for CANCELrn");

              PB1 = readPin1;
              PB2 = readPin2;

              while (PB1 == 0)
              {
                  beginProcess = 3;
              }
              while (PB2 == 0)
              {
                  printf("Cancelled rn");
                  beginProcess = 1;
              }
             break;

          case 3:

              printf("Press 1 for chequing rn");
              printf("Press 2 for savings rn");

              PB1 = readPin1;
              PB2 = readPin2;

              while (PB1 == 0)
              {
                  beginProcess = 4;
              }

              while (PB2 == 0)
              {
                  beginProcess = 4;
              }
              break;
     }
}

Cumulative update 3 and 4 caused synchronous commit errors in availability groups

So this week I was patching our SQL servers that host our availability groups. I never had a problem with them in the past, a fairly standard process. I have two servers (I call them SQL1 and SQL2) in the cluster and one Availability Group (AG1) uses SQL1 as the primary, and three Availability Groups (AG2-4) uses SQL2 as the primary. They were running v15.0.4013.40, so Server 2019 and this week I had to install CU3 and CU4.

My process was:

  1. I moved AG1 to use SQL2 as the primary
  2. Proceed to patch SQL1
  3. Change all availability groups to asynchronous commit
  4. Restart SQL1
  5. Return all availability groups to sync confirmation
  6. Return AG1 to use
    SQL1 as the primary

In step 2 I patched CU3 and then CU4 on. Then, when trying to change all the AGs to synchronize the commitment, the databases threw errors in the Availability Group Dashboard and did not allow access to their databases. I couldn't see any recorded reason why he refused to do this. It was only resolved when I then patched SQL2 with both CUs, and again allowed sync commit.

My question is does anyone else have this problem? Is this likely because I try to be efficient and patch two CUs at the same interval without doing it one by one? I'm just trying to figure out how I don't do this again since it caused me quite a headache

php7: what are the errors in this code in php?

Can you find the errors of this PHP program?

<? php


$ profile_id = $ user (& # 39; username & # 39;);
$ imgSrc = "https://serverfault.com/";
$ result_path = "https://serverfault.com/";
$ msg = "https://serverfault.com/";

if (! isset ($ _ POST (& # 39; x & # 39;)) &&! isset ($ _ FILES (& # 39; image & # 39;) (& # 39; name & # 39;))) {
$ temppath = & # 39; profile_pics /&#39;.$ profile_id. & # 39; _ temp.jpeg & # 39 ;;
if (file_exists ($ temppath)) {@ unlink ($ temppath);}
}
if (isset ($ _ FILES (& # 39; image & # 39;) (& # 39; name & # 39;))) {

$ ImageName = $ _ FILES (& # 39; image & # 39;) (& # 39; name & # 39;);


$ ImageSize = $ _ FILES (& # 39; image & # 39;) (& # 39; size & # 39;);

$ ImageTempName = $ _ FILES (& # 39; image & # 39;) (& # 39; tmp_name & # 39;);


$ ImageType = @ exploit (& # 39; / & # 39 ;, $ _ FILES (& # 39; image & # 39;) (& # 39; type & # 39;));

$ type = $ ImageType (1);

$ uploaddir = $ _ SERVER (& # 39; DOCUMENT_ROOT & # 39;). "/ profilepics";






$ file_temp_name = $ profile_id. & # 39; _ original & # 39; .md5 (time ()). & # 39; n & # 39 ;. $ type;
$ fullpath = $ uploaddir. "/". $ file_temp_name;

$ file_name = $ profile_id. & # 39; _ temp.jpeg & # 39 ;;
$ fullpath_2 = $ uploaddir. "/". $ filename;


$ move = move_uploaded_file ($ ImageTempName, $ fullpath);

chown ($ fullpath, sreekar);
chmod ($ fullpath, 0777);
if (! $ move) {
die ("the file is not loaded");

}
plus
{
$ imgSrc = "profile_pics /".$ file_name;
$ msg = "load complete";
$ src = $ filename;
}



clearstatcache ();
$ original_size = getimagesize ($ fullpath);
$ original_width = $ original_size (0);
$ original_height = $ original_size (1);
$ main_width = 500;
$ main_height = $ original_height / ($ original_width / main_width);
if ($ _ FILES ("image") ("type") == "image / gif") {
$ src2 = imagecreatefromgif ($ full path);
}
elseif ($ _ FILES ("image") ("type") == "image / jpeg" https://serverfault.com/ "|
$ _FILES ("image") ("type") == "image / pjpeg") {
$ src2 = imagecreatefromjpeg ($ fullpath);
}
elseif ($ _ FILES ("image") ("type") == "image / png") {
$ src2 = imagecreatefrompng ($ full path);
}plus{
$ msg. = "There was an error loading the file, please upload a .jpg, .gif or .png file 
"; } $ main = imagecreatetruecolor ($ main_width, $ main_height); imagecopyresampled ($ main, $ src2,0,0,0,0, $ main_width, $ main_height, $ original_width, $ original_height); $ main_temp = $ fullpath_2; imagejpeg ($ main, $ main_temp, 90); chmod ($ main_temp, 0777); imagedestroy ($ src2); imagedestroy ($ main); @ unlink ($ fullpath); } if (isset ($ _ POST (& # 39; x & # 39;))) { $ type = $ _ POST (& # 39; type & # 39;); $ src = & # 39; profile_pics /&#39;.$_ POST (& # 39; src & # 39;); $ finalname = $ profile_id.md5 (time ()); if ($ type == & # 39; jpg "https://serverfault.com/" | $ type == & # 39; jpeg "https://serverfault.com/" | $ type == & # 39; JPG "https://serverfault.com /" | $ type == & # 39; JPEG & # 39;) { $ targ_w = ​​$ targ_h = 1500; $ jpeg_quality = 90; $ img_r = imagecreatefromjpeg ($ src); $ dst_r = imagecreatetruecolor ($ targ_w, $ targ_h); imagecopyresampled ($ dst_r, $ img_r, 0,0, $ _ POST (& # 39; x & # 39;), $ _ POST (& # 39; y & # 39;), $ targ_w, $ targ_h, $ _ POST (& # 39; w & # 39;), $ _ POST (& # 39; h & # 39;)); imagejpeg ($ dst_r, "profile_pics /".$ finalname." n.jpeg ", 90); } else if ($ type == & # 39; png "https://serverfault.com/" | $ type == & # 39; PNG & # 39;) { $ targ_w = ​​$ targ_h = 150; $ jpeg_quality = 90; $ img_r = imagecreatefrompng ($ src); $ dst_r = imagecreatetruecolor ($ targ_w, $ targ_h); imagecopyresampled ($ dst_r, $ img_r, 0,0, $ _ POST (& # 39; x & # 39;), $ _ POST (& # 39; y & # 39;), $ targ_w, $ targ_h, $ _ POST (& # 39; w & # 39;), $ _ POST (& # 39; h & # 39;)); imagejpeg ($ dst_r, "profile_pics /".$ finalname." n.jpeg ", 90); } else if ($ type == & # 39; gif "https://serverfault.com/" | $ type == & # 39; GIF & # 39;) { $ targ_w = ​​$ targ_h = 150; $ jpeg_quality = 90; $ img_r = imagecreatefromgif ($ src); $ dst_r = imagecreatetruecolor ($ targ_w, $ targ_h); imagecopyresampled ($ dst_r, $ img_r, 0,0, $ _ POST (& # 39; x & # 39;), $ _ POST (& # 39; y & # 39;), $ targ_w, $ targ_h, $ _ POST (& # 39; w & # 39;), $ _ POST (& # 39; h & # 39;)); imagejpeg ($ dst_r, "profile_pics /".$ finalname." n.jpeg ", 90); } imagedestroy ($ img_r); imagedestroy ($ dst_r); @ unlink ($ src); $ result_path = "profile_pics /".$ finalname." n.jpeg "; $ insert_pic_query = mysqli_query ($ db, "UPDATE profile SET image = & # 39; $ result_path & # 39; WHERE username = & # 39; $ userLoggedIn" https://serverfault.com/ "); header ("Location:". $ userLoggedIn); } ?>

Upload something:





<img src = " "border =" 0 "id =" jcrop_target " style = "border: 0px # 990000 solid; position: relative; margin: 0px 0px 0px 0px; padding = 0px; "/>

Crop Profile Image



Crop / resize your uploaded profile picture
Once you are satisfied with your profile picture, then please click save.


<input type = "hidden" value = ""name =" src "/>
<img src = ""style =" position: relative; margin: automatic 10px; width: 150 px; height: 150 px; "/>

magento2.3 – magento 2.3.4 Errors after moving the site to the active domain within the same server

I have created a magento 2.3.4 site on a test server var / www / domain.es / developer /
Once the site is tested and working, plesk (copy site) changed the location to var / www / domain.es, but what is my surprise when I check the following

1) When I do an export, I save it in var / www / domain.es / developer / var / export

2) The files .update_status.txt .update_cronjob_status .setup_cronjob_status are still updated in var / www / domain.es / developer / and do not exist in var / www / domain.es

3) In the database cron_schedule.sales_clean_orders continue searching var / www / domain.es / developer / and give an error warning: Index not defined: simple_sku in /var/www/vhosts/domain.es/developer/vendor / magento / module- configurable-product-inventory / Plugin / Sales / GetSkuFromOrderItem.php on line 36

And more things that are possibly all related.

Any help to solve this?

rest api: Magento web API that provides internal server errors to add products

I tried to post a product on my Magento site through its REST web API. I am using curl. I have this error:

{"message": "Internal error. Details are available in the Magento log file. Report ID: webapi-5e884238b420f"}

And when I searched the log file, I found:

/var/www/html/var/log/exception.log:(2020-04-04 08:15:52) main.CRITICAL: Report ID: webapi-5e884238b420f; Message: Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "MagentoCatalogInventoryApiDataStockItemInterface". {"exception":"(object) (Exception(code: 0): Report ID: webapi-5e884238b420f; Message: Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "Magento\CatalogInventory\Api\Data\StockItemInterface". at /var/www/html/vendor/magento/framework/Webapi/ErrorProcessor.php:208, LogicException(code: 0): Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "Magento\CatalogInventory\Api\Data\StockItemInterface". at /var/www/html/vendor/magento/framework/Reflection/NameFinder.php:100)"} ()

I tried to find out what this error meant. I couldn't find much.

This is my curl request:

curl -X POST "http://167.179.118.154/index.php/rest/default/V1/products"  -H "Content-Type:application/json" -H "Authorization: Bearer " -d '{"product":{"id":0,"sku":"string","name":"string","attribute_set_id":0,"price":0,"status":0,"visibility":0,"type_id":"string","created_at":"string","updated_at":"string","weight":0,"extension_attributes":{"website_ids":(0),"category_links":({"position":0,"category_id":"string","extension_attributes":{}}),"stock_item":{"item_id":0,"product_id":0,"stock_id":0,"qty":0,"is_in_stock":true,"is_qty_decimal":true,"show_default_notification_message":true,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":0,"min_sale_qty":0,"use_config_max_sale_qty":true,"max_sale_qty":0,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":0,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":true,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"string","is_decimal_divided":true,"stock_status_changed_auto":0,"extension_attributes":{}},"bundle_product_options":({"option_id":0,"title":"string","required":true,"type":"string","position":0,"sku":"string","product_links":({"id":"string","sku":"string","option_id":0,"qty":0,"position":0,"is_default":true,"price":0,"price_type":0,"can_change_quantity":0,"extension_attributes":{}}),"extension_attributes":{}}),"configurable_product_options":({"id":0,"attribute_id":"string","label":"string","position":0,"is_use_default":true,"values":({"value_index":0,"extension_attributes":{}}),"extension_attributes":{},"product_id":0}),"configurable_product_links":(0),"downloadable_product_links":({"id":0,"title":"string","sort_order":0,"is_shareable":0,"price":0,"number_of_downloads":0,"link_type":"string","link_file":"string","link_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"link_url":"string","sample_type":"string","sample_file":"string","sample_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"sample_url":"string","extension_attributes":{}}),"downloadable_product_samples":({"id":0,"title":"string","sort_order":0,"sample_type":"string","sample_file":"string","sample_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"sample_url":"string","extension_attributes":{}}),"giftcard_amounts":({"attribute_id":0,"website_id":0,"value":0,"website_value":0,"extension_attributes":{}})},"product_links":({"sku":"string","link_type":"string","linked_product_sku":"string","linked_product_type":"string","position":0,"extension_attributes":{"qty":0}}),"options":({"product_sku":"string","option_id":0,"title":"string","type":"string","sort_order":0,"is_require":true,"price":0,"price_type":"string","sku":"string","file_extension":"string","max_characters":0,"image_size_x":0,"image_size_y":0,"values":({"title":"string","sort_order":0,"price":0,"price_type":"string","sku":"string","option_type_id":0}),"extension_attributes":{"vertex_flex_field":"string"}}),"media_gallery_entries":({"id":0,"media_type":"string","label":"string","position":0,"disabled":true,"types":("string"),"file":"string","content":{"base64_encoded_data":"string","type":"string","name":"string"},"extension_attributes":{"video_content":{"media_type":"string","video_provider":"string","video_url":"string","video_title":"string","video_description":"string","video_metadata":"string"}}}),"tier_prices":({"customer_group_id":0,"qty":0,"value":0,"extension_attributes":{"percentage_value":0,"website_id":0}}),"custom_attributes":({"attribute_code":"string","value":"string"})},"saveOptions":true}'

Is it because my JSON contains dummy data (which I just copied from the Magento web API documentation)? But I tried to modify some of the values ​​like below, and still got the same answer:

{
  "product": {
    "id": 10,
    "sku": "phone8",
    "name": "iPhone8",
    "attribute_set_id": 0,
    "price": 10,
    "status": 0,
    "visibility": 0,
    "type_id": "string",
    "created_at": "string",
    "updated_at": "string",
    "weight": 0,
    "extension_attributes": {
      "website_ids": (
        0
      ),
      "category_links": (
        {
          "position": 0,
          "category_id": "string",
          "extension_attributes": {}
        }
      ),
      "stock_item": {
        "item_id": 0,
        "product_id": 0,
        "stock_id": 0,
        "qty": 0,
        "is_in_stock": true,
        "is_qty_decimal": true,
        "show_default_notification_message": true,
        "use_config_min_qty": true,
        "min_qty": 0,
        "use_config_min_sale_qty": 0,
        "min_sale_qty": 0,
        "use_config_max_sale_qty": true,
        "max_sale_qty": 0,
        "use_config_backorders": true,
        "backorders": 0,
        "use_config_notify_stock_qty": true,
        "notify_stock_qty": 0,
        "use_config_qty_increments": true,
        "qty_increments": 0,
        "use_config_enable_qty_inc": true,
        "enable_qty_increments": true,
        "use_config_manage_stock": true,
        "manage_stock": true,
        "low_stock_date": "string",
        "is_decimal_divided": true,
        "stock_status_changed_auto": 0,
        "extension_attributes": {}
      },
      "bundle_product_options": (
        {
          "option_id": 0,
          "title": "string",
          "required": true,
          "type": "string",
          "position": 0,
          "sku": "string",
          "product_links": (
            {
              "id": "string",
              "sku": "string",
              "option_id": 0,
              "qty": 0,
              "position": 0,
              "is_default": true,
              "price": 0,
              "price_type": 0,
              "can_change_quantity": 0,
              "extension_attributes": {}
            }
          ),
          "extension_attributes": {}
        }
      ),
      "configurable_product_options": (
        {
          "id": 0,
          "attribute_id": "string",
          "label": "string",
          "position": 0,
          "is_use_default": true,
          "values": (
            {
              "value_index": 0,
              "extension_attributes": {}
            }
          ),
          "extension_attributes": {},
          "product_id": 0
        }
      ),
      "configurable_product_links": (
        0
      ),
      "downloadable_product_links": (
        {
          "id": 0,
          "title": "string",
          "sort_order": 0,
          "is_shareable": 0,
          "price": 0,
          "number_of_downloads": 0,
          "link_type": "string",
          "link_file": "string",
          "link_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "link_url": "string",
          "sample_type": "string",
          "sample_file": "string",
          "sample_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "sample_url": "string",
          "extension_attributes": {}
        }
      ),
      "downloadable_product_samples": (
        {
          "id": 0,
          "title": "string",
          "sort_order": 0,
          "sample_type": "string",
          "sample_file": "string",
          "sample_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "sample_url": "string",
          "extension_attributes": {}
        }
      ),
      "giftcard_amounts": (
        {
          "attribute_id": 0,
          "website_id": 0,
          "value": 0,
          "website_value": 0,
          "extension_attributes": {}
        }
      )
    },
    "product_links": (
      {
        "sku": "string",
        "link_type": "string",
        "linked_product_sku": "string",
        "linked_product_type": "string",
        "position": 0,
        "extension_attributes": {
          "qty": 0
        }
      }
    ),
    "options": (
      {
        "product_sku": "string",
        "option_id": 0,
        "title": "string",
        "type": "string",
        "sort_order": 0,
        "is_require": true,
        "price": 0,
        "price_type": "string",
        "sku": "string",
        "file_extension": "string",
        "max_characters": 0,
        "image_size_x": 0,
        "image_size_y": 0,
        "values": (
          {
            "title": "string",
            "sort_order": 0,
            "price": 0,
            "price_type": "string",
            "sku": "string",
            "option_type_id": 0
          }
        ),
        "extension_attributes": {
          "vertex_flex_field": "string"
        }
      }
    ),
    "media_gallery_entries": (
      {
        "id": 0,
        "media_type": "string",
        "label": "string",
        "position": 0,
        "disabled": true,
        "types": (
          "string"
        ),
        "file": "string",
        "content": {
          "base64_encoded_data": "string",
          "type": "string",
          "name": "string"
        },
        "extension_attributes": {
          "video_content": {
            "media_type": "string",
            "video_provider": "string",
            "video_url": "string",
            "video_title": "string",
            "video_description": "string",
            "video_metadata": "string"
          }
        }
      }
    ),
    "tier_prices": (
      {
        "customer_group_id": 0,
        "qty": 0,
        "value": 0,
        "extension_attributes": {
          "percentage_value": 0,
          "website_id": 0
        }
      }
    ),
    "custom_attributes": (
      {
        "attribute_code": "string",
        "value": "string"
      }
    )
  },
  "saveOptions": true
}

errors: cannot access parts of a certain site

I am trying to access specific parts of the following website, but I keep getting this error message.

Thrown error

Undefined function call simple_fields_get_post_group_values ​​()

Does anyone know why I receive this and if this can be fixed? Thank you.

How to solve these equations without errors?

I am a new user of Mathica 12. I have to plot real and imaginary solutions of two equations, eq1 and eq2, which contain the Dawson function, here is my program:

f(a_) := - 2 DawsonF(a)+I Exp(-a^2) Sqrt((Pi)) 

eq1(x1_, y_, z_) := 1 - (z y^2/x1^2) - (1/(Sqrt(2) x1 y)) f(x1/(Sqrt(2) y))
eq2(x2_, y_) := 1 - (1/(2 y^2)) f'(x2/(Sqrt(2) y))

slo1(y_, z_) := Re(x1 /. FindRoot(eq1(x1, y, z), {x1, Sqrt(1 + z y^2)}));
slo2(y_) := Re(x2 /. FindRoot(eq2(x2, y), {x2, Sqrt(1 + y^2)}));

Plot({slo1(y, 5000), slo2(y)}, {y, 0.0001, 0.5},PlotRange -> {{0.0001, 0.5}, {0, 4}}, PlotRangePadding -> 0)

When I plot the charts I get these errors

General::munfl: Exp(-4.11658*10^7) is too small to represent as a normalized machine number; precision may be lost.

General::munfl: Exp(-4.11658*10^7) is too small to represent as a normalized machine number; precision may be lost.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

General::munfl: Exp(-4.11633*10^7) is too small to represent as a normalized machine number; precision may be lost.

General::stop: Further output of General::munfl will be suppressed during this calculation.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

This means that the solutions plotted are incorrect. How to eliminate these errors to get the exact solutions?

How to draw imaginary solutions also without errors?

Thank you.