php – Pegar dados de um Banco de Dados Mysqli no Java Script

Estou desenvolvendo um simulador usando php e os cálculos em javaScript. Coisa bem simples. O cliente escolhe o valor que quer contratar, escolhe a quantidade de parcelas e o sistema retorna o valor das parcelas e o quanto ela pagará de juros. Para cada parcela clicada eu tenho um valor de taxa que vem diretamente do banco de dados, porém para fazer o cálculo eu estou inserindo de forma “engessada” os dados, pois não sei uma forma de pegar os valores diretamente do BD através do JavaScript. Meu código está assim hoje. Arquivo script.js

$(document).ready(function(){
    $('.mask-money').mask("#.##0,00", {reverse: true});
});

$('input(type=radio)(name=parcela)').on('click', function(){
    var inputParcelas = $('#valorParcelaBD').val($('input(type=radio)(name=parcela):checked').val())
    var qtdyParcelaBD = $('#qtdyParcelaBD').val($('input(type=radio)(name=parcela):checked').attr('id'))
    var valorSolicitado = Number($('#valorSolicitado').val().replace(/(^d)+/g,''))
    var parcelasclick = parseFloat($('input(type=radio)(name=parcela):checked').val());
    if(parcelasclick == 1) {
        var prazo = 1
    } else if(parcelasclick == 2) {
        var prazo = 2
    } else if(parcelasclick == 10.172047)// Preciso pegar esse valor de uma coluna de uma tabela no Banco de Dados {
        var prazo = 3 // Preciso pegar esse valor de uma coluna de uma tabela no Banco de Dados
    } else if(parcelasclick == 8.457329)//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados{
        var prazo = 4// Preciso pegar esse valor de uma coluna da mesma tabela no Banco de Dados 
    } else if(parcelasclick == 7.322438)//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados  {
        var prazo = 5 // Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados
    } else if(parcelasclick == 6.515287) {
        var prazo = 6// Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados 
    } else if(parcelasclick == 5.91142)//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados {
        var prazo = 7//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados
    } else if(parcelasclick == 5.442319)//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados {
        var prazo = 8//Preciso pegar esse valor dinamicamente de uma tabela no Banco de Dados
    } else if(parcelasclick == 5.067154) {
        var prazo = 9
    } else if(parcelasclick == 4.760078) {
        var prazo = 10
    } else if(parcelasclick == 4.503933) {
        var prazo = 11
    } else if(parcelasclick == 4.28688403) {
        var prazo = 12
    } else if(parcelasclick == 4.1005) {
        var prazo = 13
    } else if(parcelasclick == 3.938613) {
        var prazo = 14
    } else if(parcelasclick == 3.796609) {
        var prazo = 15
    } else if(parcelasclick == 3.670964) {
        var prazo = 16
    } else if(parcelasclick == 3.558944) {
        var prazo = 17
    } else if (parcelasclick == 3.4264882) {
        var prazo = 18
    }
    var juros = (parcelasclick / 100) 
    var parcela = (valorSolicitado * juros) / (1 - Math.pow(1 / (1 + juros), prazo))
    var total = parcela * prazo;
    console.log('Input Parcelas: ' +inputParcelas)
    console.log('Valor Solicitado: ' +(valorSolicitado/ 100).toFixed(2))
    console.log('Taxa de Juros aplicada: ' +juros)
    console.log('Valor das Parcelas: '+(parcela/100).toFixed(2))
    console.log('Prazo: ' +(prazo).toFixed(2))
    console.log('Total ' +(total / 100).toFixed(2))
   
    $('#limiteNecessario').val((total / 100).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' }));
    $('#valorParcela').val((parcela / 100).toLocaleString("pt-BR", { minimumFractionDigits: 2 , style: 'currency', currency: 'BRL' }));
    
});

magento2.4.2 – Exception #0 : Notice: Trying to access array offset on value of type null in ../Calendar.php PHP 7.4

I did a new installation of Magento 2.4.2 (PHP 7.4.3). There were no errors during the installation.
The ShopURL is running.
The backend login also works.
After I switched the backend to German, the following error message occurs:

"Exception #0 (Exception): Notice: Trying to access array offset on value of type null in /myPath2project/shop/vendor/magento/framework/View/Element/Html/Calendar.php on line 114"

Where could I start to solve the problem.

Thanks in advance
Greetings heiko

Using IIS 10 (PHP yes) what is the best practice for allowing iframes of a site?

I have a W2016 server with IIS 10 running on it and I am having problems implementing policy (used to apache) on how to add in the correct headers for Content Security Policy/CORS/X-frame. It seems that IIS has gone out of its way already to add SAMEORIGIN by default, as I don’t see it listed anywhere (the server or the site in question).

So what is the best way to ensure that mysite.example.com can be iframed into any site and also if I want to lock down iframing can I have a policy to allow iframing on the wildcard of the root – so *.example.com.

mysql – Error migrar una aplicacion PHP

Tengo una aplicación web en php (la hizo el que estaba antes que yo) en local. Me han pedido de migrarla a la nube, básicamente es añadir datos de empresas a la base de datos. En local funciona perfectamente, pero lo he migrado a una VM en azure, le he instalado LAMP y lo que es la página funciona correctamente, se ve y se puede navegar, pero ha perdido la funcionalidad, me explico:
Antes de la migración se podían rellenar los campos de las empresas y se enviaban a la base de datos, pero ahora en azure no, he cambiado el archivo php de la base datos, y lo que es login funciona por lo que puede acceder a la base datos, pero al insertar datos de empresas, me da este error:

Fatal error: Uncaught DelightFileUploadThrowableTotalSizeExceededError in /var/www/html/BotCamara/panel/vendor/delight-im/file-upload/src/AbstractUpload.php:60 Stack trace: #0 /var/www/html/BotCamara/panel/vendor/delight-im/file-upload/src/AbstractUpload.php(85): DelightFileUploadAbstractUpload->withMaximumSizeInBytes(5242880) #1 /var/www/html/BotCamara/panel/requerimentSubmitter.php(90): DelightFileUploadAbstractUpload->withMaximumSizeInMegabytes(5) #2 {main} thrown in /var/www/html/BotCamara/panel/vendor/delight-im/file-upload/src/AbstractUpload.php on line 60

Error AbstractUpload.php:60:
introducir la descripción de la imagen aquí

Error AbstractUpload.php:85:
introducir la descripción de la imagen aquí

Error requerimentSubmitter.php(90):
introducir la descripción de la imagen aquí

Parece que el problema ha sido subir el archivo PDF, pero el PDF pesa menos de 5MB que es el límite. Por ultimo he probado a realizar los mismo en la aplicación en local y con el mismo PDF no me ha dado problema al subirlo.

Dejo también el directorio de la app, por si puediera servir de algo, la VM solo tiene apache, mysql y php php-mysql, y lo que es todo el directorio está copiado y pegado de local a la nube por lo que los archivos son los mismo a excepción de la comunicación con la base de datos. Se “ve”, pero no “funciona”.
introducir la descripción de la imagen aquí
Espero me puedan ayudar.

Un saludo

php – WordPress schedule event function not running

I am totally new with the schedule event from WordPress.
For my theme I created a function that must run every minute.
To test my scheduler I created a test function that send me an email.
But I do not receive an email and I think my scheduler is not working.
Please who can help me a bit?
Below my code so far

add_action( 'my_test', 'test_scheduler');
add_filter( 'cron_schedules', function ( $schedules ) {
   $schedules('per_minute') = array(
       'interval' => 60,
       'display' => __( 'One Minute' )
   );
   return $schedules;
} );

//create event after theme setup
add_action("after_setup_theme", function(){
    if (! wp_next_scheduled ( 'my_test' )) {
        wp_schedule_event( time(), 'per_minute', 'my_test' );
    }
});

//delete event if theme is deactivated
add_action('switch_theme', function(){
    wp_clear_scheduled_hook( 'my_test' );
});

The code above is in the functions.php file.

php – error en mediasmoviles chartseries en RStudio

Una manera para analizar cambios de
tendencia sobre las criptomonedas es utilizando
medias móviles sobre las series temporales.
Por cada moneda debe construir tres nuevas series,
considerando una media móvil a 40, 20 y 10 días.
Construya una función en R que retorne una nueva
serie construida a partir de medias móviles. Esta
función debe recibir como parámetros de entrada: la
serie de datos original de la moneda en análisis y el
número de días a considerar en la media móvil.
Genere un gráfico de líneas que considere la serie
original y las tres series con medias móviles. Analice
las tendencias de las tres medias móviles y describa
sus hallazgos.
Denomine a su función:
“funcion_medias_moviles”

al intentar de solucionar este problema pongo esto:

candleChart(df_bitcoin,name="MEDIAMOVIL",theme = "white",
            subset = "2020-03-01": "2021-02-28",
            TA="addVo();addSMA(n=40,col=2);addSMA(n=20,col=3);addSMA(n=10,col=4)")

y siempre me aparece este error:

Error in try.xts(x, error = "chartSeries requires an xtsible object") : 
  chartSeries requires an xtsible object

por favor si alguen sabe solucionar en que parte me estoy equivocando

php – WordPress VS React?

Our website is currently built on WordPress…most of the website (homepage, blogs, pages, etc…)
We use React for parts of the website (product and equipment pages that use facets/filters to sort through products).

WordPress is fairly simple to work with, but can get buggy with conflicting plugins, updating WordPress versions, etc… However creating page templates, pages, blogs, etc… is fairly simple and quick to work with. All pages are fully responsive for desktop and mobile.

I want to keep elements of the website with WordPress (homepage, blogs, pages, etc…) due to their ease of use and great page speed.
Some people at our company want to convert everything to React and get rid of WordPress.

Any reasons why we should keep parts of the website in WordPress and not convert to React?

Create PHP contact form using php

Hi, I’m a new intern at a company and I’m trying to create a website with a contact form that emails a specific address when filled out. I d… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1843761&goto=newpost

php – Searching for best practice – Long calculating method

I’m working on a Laravel project for engineers. The software calculates the stability and pressure for specific wooden connections.
As you can imagine, depending on the connection, there are many calculations with many values to be done.

First, there was the approach make one calculation function / method for one connection type (inside the connection type class), where all neccessary fields are calculated.
Then it came up to my mind, to create a method to calculate each value seperately:

public function calculateConnection($connectionValues) {
   $connection->a = $this->getAValue($connectionValues);
   $connection->b = $this->getBValue($connectionValues);
   ...
}

public function getAValue($connectionValues) {
   return ...
}

public function getBValue($connectionValues) {
   return ...
}

I have a much better overview about the specific values, when creating a function for each value instead of calculating everything in one method, but the issue is, that the values are depending on each other. So value a is needed to calculate b.

So all methods need to be called in the correct order. Of course, I can do a check, if a is already been calculated, before doing the calculation of b, but this will blow up the code so much.

I’m interested, what is best-practice in this kind of situation.

php – Magento2.4.2 Create order Programmatically not working

I’ve tried a viral solution and followed this https://webkul.com/blog/create-quote-and-order-programmatically-in-magento2/

The quote is created successfully but error occurred when place order

$orderId = $this->cartManagementInterface->placeOrder($quote->getId());

And the following error occurred

Type Error occurred when creating object: MagentoInventoryIndexerModelQueueReservationData, Argument 2 passed to MagentoInventoryIndexerModelQueueReservationData::__construct() 

must be of the type int, null given, called in /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121