PHP error reporting 22527?

My PHP is returning an error code of 22527. I can’t find anything on the error. Here’s my PHP, I don’t own the server it’s hosted off so I can’t see error reporting.

<?php
error_reporting(E_ALL);
$name = strval($_GET['name']);
$bid = strval($_GET['bid']);
$electricity = strval($_GET['electricity']);
$water = strval($_GET['water']);
$other = strval($_GET['other']);
$table = strval($_GET['table']);

$con = mysqli_connect('localhost','X','X','X');
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
} else {
$sql="SELECT * FROM m1 WHERE name = '".$name."'";
$result = mysqli_query($con,$sql);
if ($result->num_rows > 0)  {
    echo "pop";
} else {

$sql = "INSERT INTO m1 (name, bid, electricity, water, other, tableVal)
VALUES ('$name', '$bid', '$electricity', '$water','$other','$table')";

mysqli_query($con, $sql) {
    echo "okay";
} else {
    echo "error";
}
    }
mysqli_close($con);
}
?>

Thanks.


Source: stackoverflow-php

Woocommerce caches cart (Combined with W3 Total Cache)

I’ve experienced a weird issue on a site using WordPress + Woocommerce recenty. The site uses W3 Total Cache for page cache and browser cache and although i’ve set the woocommerce_cart_items cookie in the rejected list for page cache, the front page is beeing cached .
As a result i’ve issues with the cart ,empty on front page as is served as static, in other shop pages are regenerated and everything is fine.
To my understanding, pages are supposed to be cached if the cookie woocommerce_cart_items is missing ( so we have a guest customer browsing ), and after a product is added in the cart, woocommerce created a session and the cookie is stored so next time the frontpage is called it’s beeing regenerated and not served as static, is that right?
Is there a way to ensure this functionality?

Is this affected depending on the caching option selected (disk, apcu …)? if i decide to use redis for page cache , which is the best way to exclude such things from beeing cached?


Source: stackoverflow-php

Javascript Arrow Function

I am running both the code blocks in chrome console but I am not able to
understand why is the output of second block NaN.The value passed should in the second case doesn’t include b, which should not matter is what I think.

var adder = {
  base: 1,

  add: function(a) {
    var f = v => v + this.base;
    return f(a);
  },

  addThruCall: function(a,n) {
    var f = (v,n) => v + n + this.base;
    var b = {
      base: 2
    };         
   return f.call(b,a,n);
  }
};
console.log(adder.addThruCall(3,4)); // output: 8

But when I do

var adder = {
 base: 1,

 add: function(a) {
   var f = v => v + this.base;
   return f(a);
 },

 addThruCall: function(a,n) {
   var f = (v,n) => v + n + this.base;
   var b = {
     base: 2
   };         
   return f.call(a,n);
 }
};
console.log(adder.addThruCall(3,4)); //output: NaN


Source: stackoverflow-javascript

Concat on ng-model in AngularJS

I have a problem with an ng-model, I want to create a “dinamic” ng-model with an $index, inside a ng-repeat.

I call an API and that response an object , with the following structure

{
 rules: {
   rule1: "value1",
   rule2: "value2"
 }
}

I am trying to put it dinamicly into ng-model like this.

<input type="text" ng-model='dc.dataToPass.rules["rule"+$index+1]' ng-model-options="{ updateOn: 'blur' }" required />

But does not work propertly.

I hope you can help me,

Any idea? Thanks!!

Regards!


Source: stackoverflow-javascript

JSP doesn’t show cookie for the first time

I set a cookie in javascript, not in controller and I want to check if that cookie exists in JSP. My cookie is set, but I have to reload the page manually in order to see it in jsp. I did reload method in javascript, but I still have to reload page once more.

JSP:
getting cookie: ${cookie['_sYrV'] } or ${cookie._sYrV }

Javascript:

set_cookie("name","value", 1);
window.onload = function () {
    if (!localStorage.reloadOnce) {
        localStorage.setItem("reloadOnce", "true");
        window.location.reload();
    }
}

var set_cookie = function(name, value, day) {
    var d = new Date();
    d.setTime(d.getTime() + (day * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = name + "=" + value + ";" + expires + ";path=/";
};

What should I do in order to see the cookie in jsp without reloading the page manually?


Source: stackoverflow-javascript

Loading a config file parameter in Angular2

I have a problem which I know has solutions but I am not sure how to implement it. I have a file that reads a server URL in src folder. But depending on the environment configuration, i need to read the server URL from the root folder into the typescript file in src folder. How can it be done?

Currently in my ts file, i have this line

export const ServerURL = <serverURL>;

I am importing this file into other components which uses the server URL.

import { ServerURL } from '../file-path';

Now I need to read this ServerURL from a config file in the root of this application.Do we use a seperate js or JSON file to read the server URL or do can it be done in the systemjs.config.js file which is one of the main file of the application? Any advice would be great!


Source: stackoverflow-javascript

Angular if else condition for ng-options in a dropdown

I have a dependent dropdown and in my app, i am using the angular translator based on the language selection dropdown options must change.If language is English then options must be English else in another language.How to apply if else condition so based on language selection options must load.

Dropdown Options in controller

 $scope.Districts =[
       {
         'id': '1',
          'name': "ಬಾಗಲಕೋಟೆ",
          'Talukas': [{
             'id': '11',
             'dep': "ಬಾದಾಮಿ"
         }, {
             'id': '12',
             'dep': "ಬಿಳಗಿ"
         },
            { 'id': '13',
             'dep': "ಹುನಗುಂದ್"
         },{
             'id': '14',
             'dep': "ಮುಧೋಳ್"
         },
            { 'id': '15',
             'dep': "ಜಮಖಂಡಿ"

         }]
       }];

  $scope.Districts =[
   {
     'id': '1',
      'name': "Bagalkot",
      'Talukas': [{
         'id': '11',
         'dep': "Badami"
     }, {
         'id': '12',
         'dep': "Bilgi"
     },
        { 'id': '13',
         'dep': "Hungund"
     },{
         'id': '14',
         'dep': "Mudhol"
     },
        { 'id': '15',
         'dep': "Jamkhandi"

     },{ 'id': '16',
         'dep': "Mahalingpur"
     }]
}];

html

<select id="District" ng-model="selectedDistrict" ng-options="District.id as District.name for District in Districts track by District.id">
<option value="">{{'SELECT'| translate}}</option>

<select id="Taluka"  ng-model="selectedTaluka"  ng-disabled="!selectedDistrict" ng-model="selectedTaluka" ng-options="Taluka.id as Taluka.dep for Taluka in ((Districts  | filter:{'id':selectedDistrict})[0].Talukas) track by Taluka.id" required>
     <option value="" >{{'SELECT'| translate}}</option>


Source: stackoverflow-javascript