Posts by Allan Andrade • 6,409 points
206 posts
-
2
votes0
answers35
viewsQ: Calling classes from strings in ES6 modules (commonjs) compiled by Webpack
In a web project with TypeScript, using modules commonjs, compiled via Webpack (version 5), I need to call classes and methods dynamically from type variables string containing their names. I can…
-
0
votes0
answers105
viewsQ: Unit tests with JEST, on Node.Js, without using module.Exports in Javascript code files
With both files below (ePar.js and ePar.test.js) in the same folder, how to perform the unit test, with the JEST, via Node.Js, of function ePar (in the archive ePar.js) WITHOUT ALTERING THE SAME? I…
-
0
votes1
answer280
viewsA: Even numbers in an array with for - PHP
I found two flaws in your code: 1) You wrote that for should be repeated while i for greater than the number of items in the array, while actually it should be repeated while i for minor than the…
-
1
votes4
answers140
viewsA: Exercise: Quick replacement
To meet the requested situation, just use the function below: Note: The above function only replaces the first occurrence of the string, so it will not meet the cases where the word to be replaced…
-
1
votes2
answers57
viewsA: Java script: get the element by ID says it is NULL
ID name has to be passed as string. Instead of (n1) and (N2), it has to be ('n1') and ('N2') or ("n1") and ("N2"), single or double quotes to indicate that it is string. Another point is that you…
-
0
votes4
answers1204
viewsA: Capture the value of a text without the mask?
In a row: valor = $("input[type='text']").get(indice).value.toString().replace(/[^\d]+/g, '');
-
7
votes1
answer68
viewsQ: Why is there result divergence depending on how the regular expression is executed in Javascript?
What is the reason for the result divergence found when executing the same regular expression in different ways in Javascript? Regular expression:…
-
1
votes1
answer58
viewsQ: Regular expression: how to apply "Negative Lookahead" to only one capture group?
In a domain validation task, I need a regular expression to validate them by following some rules, among them, where the domain name does not only contain numbers. Therefore, I created a regular…
-
9
votes1
answer188
viewsQ: Instantiate a class from its name in a string, without using "Eval" and in Chrome (V75+)
I need to instantiate a class from a string. Turns out for some reason it doesn’t work the way I used to: class MinhaClasse{ meuMetodo(){ alert('Método Funciona!'); } } let nome_classe =…
-
1
votes1
answer102
viewsA: PDO execute returns true but does not insert
Some considerations about your code: A) If the field Data be the type date, the format should be 'yyyy-mm-dd', which in its case would be: '2019-02-05' and not '05/02/2019'. B) Test the example…
-
0
votes1
answer74
viewsA: I am doing an image insertion with jquery ajax and php but the move_uploaded_file is not working it does not send anything
In the code PHP, there is an error in the variable value $diretorio. $diretorio = '/http://localhost/servidor/img/'; It should have the complete path from where the upload files will be stored.…
-
0
votes1
answer1439
viewsQ: "PDO" class not found after upgrading from PHP 7.2.13 to PHP 7.3.0 in Debian 9
On a Debian 9 server, I upgraded PHP from version 7.2.13 to version 7.3.0, but now PDO no longer works. Fatal error: Uncaught Error: Class 'PDO' not found. The libs are already installed: root@/#…
-
0
votes1
answer91
viewsQ: Private method in JAVASCRIPT class
How to define a private method in a class JavaScript in order to make the method msg_privada as private (not externally visible) without changing the rating pattern? The method msg_privada must be…
-
0
votes1
answer365
viewsQ: Chart.js Different color for Negative/Positive Chart bars
Chart js.: Trying to put one color for positive values and another color for negative values on the chart. Works well if there is at least one negative value: Behold…
-
3
votes3
answers1789
viewsA: Pagseguro notifications: Unable to resend the notification
After much research and testing, I discovered that despite Paying inform that it accepts TLS certificate v1.1, in fact it only accepts TLS v1.0. For this, in the configuration of the SITE in Apache,…
phpanswered Allan Andrade 6,409 -
1
votes2
answers107
viewsA: SQL query returning null value
A way would be like this: $sth = $conecta->prepare('SELECT * FROM nfe WHERE id = ?'); $sth->execute(array($nNFe)); $rs = $sth->fetchAll(); print_r($rs);
-
3
votes3
answers918
viewsA: How do I make the OPTIONS list of a SELECT transparent?
After searching a little, I couldn’t find any solution that works with all browsers, specifically with Google Chrome. This is because of how the Browser renders the component SELECT. If you can use…
-
1
votes1
answer228
viewsA: Gulp task using (usemin)
Four steps: STEP 1: Install the npm del package: npm install --save del Following steps change your Gulp file (example: gulpfile.js) STEP 2: include the command del: del = require('del'); STEP 3:…
-
7
votes2
answers1567
viewsA: How to handle string to avoid SQL Injection?
It is worth noting that mysql_real_escape_string is OBSOLETE (see in the documentation in English)! Warning This Extension was deprecated in PHP 5.5.0, and it was Removed in PHP 7.0.0. Instead, the…
-
3
votes1
answer448
viewsQ: How to make Chosen ignore accents in the search?
I’m using the Chosen on my forms, but I’d like him to ignore the accents when filtering. For example: In a city listing, filter the correctly to: - africa But it does not filter to (because the…
-
3
votes2
answers10959
viewsA: How to select between dates
You can use multiple filters on WHERE, just put AND among them. For an interval between two dates, use BETWEEN. Remember that dates need to be in quotes and in yyyy-mm-dd format. Example below:…
-
3
votes1
answer190
viewsQ: Chosen Jquery: remove selection by typing DEL
In the example Chosen - Allow Deselect on Single Selects the possibility to uncheck the selection is implemented. But the same only works with the mouse, IE, with the keyboard has no (not…
-
3
votes1
answer294
viewsA: Best way to make PHP Schedule
Scheduling for PHP via CRON (crontab) is the way I’ve been using it for some time, and without headaches. I can not say if there is any better way, maybe even have, but I can say that the PHP…
-
4
votes2
answers141
viewsA: Sort Mysql results using two tables
Follow an example of a query: SELECT t.NOME_TOPICO , count(c.id) qtd_comentarios FROM TABELA_TOPICOS as t left join TABELA_COMENTARIOS as c on c.fk_uf = t.id group by t.id order by count(t.id) desc…
-
6
votes1
answer180
viewsA: When to use console.clear?
The console.clear is used to clear console messages, which are usually written with console.log. It aims to make it easier to read the LOG information in development/test environment, in code…
javascriptanswered Allan Andrade 6,409 -
3
votes2
answers1170
viewsA: How to check whether an image (physical file) exists on an external web server via an absolute URL
You can do it in many ways. In addition to the option quoted by @Lucas Caires, it could be... Using get_headers: $arquivo = 'http://www.seu_dominio.com.br/seu_caminho/absoluto/arquivo.jpg';…
phpanswered Allan Andrade 6,409 -
3
votes2
answers435
viewsA: Javascript regular expression to validate user name size
Try this to capture exact line: /^[a-z0-9_\.-]{2,255}$/ Play by the rules: Between 2 and 255 characters In low box (Lower case) Contains only alphanumerics, unerline (_), dot (.) or hyphen (-).…
-
2
votes1
answer42
viewsA: Pass error variables between two php files
Some problems found: The action of your form is pointing to another file, so PHP leaves file index.php and call the file php/form.php, and the latter does not contain the form, so it would not…
-
1
votes1
answer45
viewsA: How to calculate a website’s Rankpage
There are several sites with these features, see some below: I really like this: https://www.prchecker.info/check_page_rank.php Follow others http://checkpagerank.net/ https://www.prchecker.info/…
seoanswered Allan Andrade 6,409 -
2
votes2
answers139
viewsA: Because when I click the button to perform the function of showing an invisible form it shows the form but then disappears?
Follow code snippet working. Only run to check. function carrega(){ document.getElementById("form2").style.display = 'none'; }; function muda1() { document.getElementById("form1").style.display =…
javascriptanswered Allan Andrade 6,409 -
2
votes1
answer62
viewsA: Add item with different array
That’s what you need? $sql = 'INSERT INTO tabela (nome, data) VALUES '; for($i = 0; $i < count($array['dependentenome']); $i++){ $sqlValues[] = "('{$array['dependentenome'][$i]}',…
-
3
votes1
answer1601
viewsQ: PHP PDO error handling
In PHP, how to make the PDO not to issue FATAL error, so that it is possible to identify and treat the error occurred? Example: Table: tb_requests: id fk_products Qtd 1 5 5 2 7 2 3 2 13 Table:…
-
5
votes2
answers4468
viewsA: Input mask with zeros on the left
Without using external libs, besides the jQuery you already use, I did the example below with the requested formatting. UPDATE 01: I CHANGED IT TO THE EVENT keyup UPDATE 02: LIMITATION OF 4…
-
2
votes2
answers92
viewsA: Date calculations in the query
Follow an example: SELECT curdate() hoje, Data_operacao , DATEDIFF(curdate(), Data_operacao) as dias , ( case when DATEDIFF(curdate(), Data_operacao) <= 3 then 0 else (DATEDIFF(curdate(),…
-
-1
votes2
answers359
viewsA: Timeout when trying to access a HTTPS Rest service via PHP
To test, try to allow the source: header('Access-Control-Allow-Origin: *'); // libera acesso de todos os sites If successful, replace the asterisk with the URL of the domain you are using.…
-
1
votes2
answers308
viewsA: How to store AJAX return to use as a parameter of another function
After $('#imprimir-danfe').removeAttr('disabled');.... puts: $('#imprimir-danfe').attr('meu_valor', chave ); And then just take the value of the key: var imprimir_d =…
-
1
votes2
answers514
viewsA: Take value from within a function
You can do a CALLBACK, passing the parameter to a new method, because when the AJAX result arrives, the function/method has probably already been executed. Below is an example (not tested):…
-
1
votes2
answers2420
viewsA: POST php com charset utf-8
In your connection code was not informed the charset of connection. Set the connection charset by adding ;charset=utf8 at the end of the connection string, example: $conn= new…
-
1
votes1
answer28
viewsA: Problem with PHP program
Your mistake is just a misspelled semicolon. <?php function linha($semana){ echo "<tr> <td>{$semana[0]}</td> <td>{$semana[1]}</td> <td>{$semana[2]}</td>…
phpanswered Allan Andrade 6,409 -
4
votes1
answer1751
viewsA: Improve slow query performance on MS SQL SERVER
Try to change the clause where for the example below. Check if it improves something: where pes_codigo_fk = 834 and crec_dataVencimento BETWEEN '2015-01-01' and '2016-01-01' and crec_dataExclusao is…
-
3
votes2
answers4279
viewsA: Can setting run-time to infinity affect server performance?
Can compromise performance yes. Setting the run limit to ZERO can cause slowdowns or even crashing your server. See the maximum time needed, then set a slack. Is there any reasonable or recommended…
-
2
votes2
answers1411
viewsA: Separate the backend frontend or not?
There is no correct or wrong answer to this question. In my opinion... separating you win: Less demand for Internet link and server resources. Technology-independent and separate codes (can change…
-
2
votes4
answers469
viewsA: json_encode returning HTML tags
Your code is returning an error message: The variable v_prod_total is not defined. In the file: C: wamp64 www nfe admin nfephp-master examples Nfe 4.00testaMakeNFe.php Row: 464 Besides this, check…
-
3
votes3
answers137
viewsA: Function to double salaries in n installments?
I made some adjustments: Function: function DesdobraParcelas($ValorTotal, $QtdeParcelas, $DataPrimeira) { if ($QtdeParcelas > 1) { //se a quantidade parcelas for maior que 1 declaro o array e…
-
2
votes1
answer63
viewsA: Hexadecimal string cut when doing Insert with PDO
The rray that’s right. For large content (type BLOB for example), you must enter the data type: PDO::PARAM_LOB The code would look like this: $sql = "INSERT INTO arquivos (arquivo) Value(:Arquivo)";…
-
0
votes1
answer81
viewsA: insertion in related tables
Since your code is not complete, I don’t know exactly how it was implemented. NOTE: I wouldn’t use the header('Location:...., would make the CLIENT class instantiating the PHONE class. Anyway, it…
-
2
votes2
answers1678
viewsA: How to change the select text after an option is chosen?
I don’t know if I understand exactly your demand, but below is a functional example and jQuery. // id do select var objeto = $("#ddi"); // salva o texto atual para poder ser recuperado…
-
7
votes1
answer510
viewsA: Problem with bindParam - PHP
There is an error in the way you implemented BIND. Where has $stmt = bindParam should be $stmt->bindParam See example below: <?php require_once 'init.php'; // Pega os dados do formulario $nome…
-
1
votes3
answers1789
viewsQ: Pagseguro notifications: Unable to resend the notification
Before asking this question, I read all the existing questions about "pagseguro notifications". At SANDBOX, I’m not receiving transaction notifications. I’m testing on a valid domain, hosted on a…
phpasked Allan Andrade 6,409 -
10
votes2
answers16210
viewsA: Mysql returning "Group By" error after upgrade to version 5.7
All fields that are in SELECT and are not using functions (such as COUNT, SUM, AVG, MAX, MIN, etc.) must be in the GROUP BY clause. In your case, as you are using asterisk, you should have all…
mysqlanswered Allan Andrade 6,409