Posts by Valdeir Psr • 10,804 points
433 posts
-
2
votes3
answers785
viewsA: PHP result on the same screen
As mentioned by Guilherme, in the comments of the question, use the function isset, it will check whether the value exists or not, for example: <?php /* Se existir o índice `submit` em $_POST,…
-
1
votes1
answer56
viewsA: Ajax does not send image to folder with PHP
Problem in the Javascript In the PHP, both variable names, how many index names are case-sensitive, so you should take care of those differences between upper and lower case. You can do the…
-
1
votes2
answers329
viewsA: Browsing history with history.pushState
You can use the event onpopstate to detect when the user clicks back, for example: window.addEventListener("popstate", event => { console.log( event ) AbreEmDIV( event.state.Url ); }); For this…
-
2
votes2
answers374
viewsA: git hub ! [Rejected] - I can’t find the files for github
The error displayed happens basically in the following situation: Changes are made to the remote repository and these changes are not applied to the local repository In your case, the error message…
-
2
votes5
answers73
viewsA: Calculate date difference and print these days
You can use a repeat loop. Just capture the return in days and use a for, for example: $data_inicio = new DateTime("08-02-2018"); $data_fim = new DateTime("10-03-2018"); $dateInterval =…
-
2
votes1
answer54
viewsA: Saving PHP code saved in Mysql
If you want to convert these codes to use as an example in your application... Follow the tip. Uses the function htmlentities to encode PHP code. This function will convert all applicable characters…
-
0
votes1
answer187
viewsA: Infinite scroll no foreach
As I commented earlier, it is necessary to separate PHP from HTML. In this case we will create a file called loadChannels.php, with the following code: <?php header("Access-Control-Allow-Origin:…
-
1
votes1
answer207
viewsA: how to block an action in a form
The first step is to change the upload button. Ideally, it should be of the type button, for example: type="button". This will prevent the form from being sent. <button onclick="asd()"…
-
1
votes1
answer216
viewsA: preg_match_all, regular expression in php with variables
It’s probably not working because you’re escaping the quotes unnecessarily. You only need to escape these quotes, when the function starts with them, for example preg_match_all("necessário \"…
-
1
votes1
answer69
viewsA: How to use bootstrap Carousel in a wordpress theme
This happens because the function is running right after it is created (even before the script of Bootstrap be - fully - loaded). The ideal is to use jQuery.ready(function($) { console.log("teste");…
-
1
votes1
answer82
viewsA: Show Ajax Output in each div
It turns out you’re generating resultado_debitoquitar_debito3, so you’re not getting. How are you capturing the ID of the form and it consists of quitar_debitoX, for example, it makes no sense to…
ajaxanswered Valdeir Psr 10,804 -
5
votes3
answers1344
viewsA: Convert String to double in Java
The function is correct. You can use both Double.parseDouble, how much Double.valueOf, but both methods will return the exception Numberformatexception case to string is invalid, for example, using…
-
-1
votes1
answer57
viewsA: Error Login System
You probably got confused mysql_ with mysqli_. The first error presented in the question is because you reversed the variables in mysql_query($con,$sql);, when the right thing is: mysql_query($sql,…
phpanswered Valdeir Psr 10,804 -
1
votes1
answer1833
viewsA: How to add parameter in nodejs
Just use process.argv[2]. This property will store a read-only copy of the original value of argv[0] past when the arquivo.js was initiated. function hello(name) { console.log("hello " + name); }…
-
2
votes1
answer101
viewsA: How to make an alert close to the return date?
How Laravel, by default, uses the Carbon to work with dates, you can simply add x days and check if this new date is equal to the current date, for example: $alert =…
-
0
votes2
answers90
viewsA: Php error api youtube
This happens because you are not setting up a valid certificate in the settings of openssl in your PHP. There are several alternatives to fix or "circumvent" this problem Downloading and configuring…
-
3
votes1
answer41
viewsA: Fitrar array PHP
Yes. You can use the function array_filter. With this function you need to pass a array and a function of callback who will be responsible for returning true or false. In this function you can put…
-
2
votes2
answers232
viewsA: Sum json object with pure js
You can also use Object.assign to "merge" two objects, for example: let obj1 = {A:1, B:2}; let obj2 = {A:4, C:3}; obj1 = Object.assign(obj1, obj2) console.log(obj1);…
javascriptanswered Valdeir Psr 10,804 -
2
votes4
answers2255
viewsA: Changing CSS by class in Javascript, is it possible?
I wonder if it is possible to make changes to the CSS of a class by Javascript. Yes, it is possible to change CSS classes through Javascript, for this you just need to use…
-
1
votes1
answer188
viewsA: Javascript - Quiz
You forgot to use the grave accent in some snippets of code, for example: answers.push( <HTMLLabelElement> <input type="radio" name="questions${questionNumber}" value="${letter}">…
-
17
votes3
answers971
viewsA: How to find "Happy Numbers" within an interval?
Another way to do it is by breaking the string and using Math.pow in each of the "pieces", for example: function beHappy(value) { let repeat = []; /** * Verifica se o valor é maior que 1 e se * o…
-
8
votes3
answers9287
viewsA: Convert string to Date (dd-mm-yyyy)
You can "explode" the values by separating them by the bar. For example: /* Separa os valores */ let dataString = "01/04/2012".split("/"); /* Define a data com os valores separados */ let data = new…
javascriptanswered Valdeir Psr 10,804 -
4
votes2
answers39
viewsA: Open popup when specific link
You can do so much with window.location.href and check the URL, for example: if ( !!location.href.match("https?:\/\/pt.stackoverflow.com\/?$") ) { alert("Página inicial") } Or you can do with…
javascriptanswered Valdeir Psr 10,804 -
4
votes1
answer47
viewsA: Why, when I compare 1000 and 500, is 500 always higher in this function in JS?
The function prompt returns a text value (a String). When you want to compare numbers, you have to use integer type values. For this just use parseInt or new Number, for example: function…
javascriptanswered Valdeir Psr 10,804 -
3
votes1
answer274
viewsA: Event . jquery Keypress is not being enabled
The way you’re doing, you’re adding the event keypress in a table element. This is not possible. To fix move the event keypress out of the event click of the element td and add the name, identifier…
-
2
votes1
answer44
viewsA: Javascript function does not execute when selecting a radio button
The mistake is in function mostraCampoArray(int numeroDoCampo). The Javascript is a weak typing language, meaning it is not necessary to inform the type of the variable, as in Java, GoLang etc.. The…
-
1
votes1
answer36
viewsA: Error in consultation
This error happens when there is an error in query. The method query of extension MySQLi, can return 3 results: false: In case of failure, for example, when the query is invalid; MySQLi_Result: If…
-
1
votes1
answer357
viewsA: Request ajax with Slim
The first parameter of the callback when registering the route, is precisely the requisition information. To capture this information, just pass a variable to have access to request and then use the…
-
1
votes1
answer1918
viewsA: Send variables via GET by php Ajax
To send data with jQuery.ajax, simply enter the attribute data configuration. This attribute will contain the information that should be sent, either via POST, or GET, for example: $.ajax({ url:…
-
0
votes1
answer242
viewsA: How to extract a value from a JSON return
Use the function json_decode. This function will return you one objeto or a array, for example: <?php $json = <<<JSON { "cep": "11702-705", "logradouro": "Avenida Presidente Castelo…
-
3
votes1
answer49
viewsA: Different colors in cells
You can do with Javascript, as well as adding direct in PHP. With Javascript you can use the jQuery or Vanilla (Js Pure). In both cases just filter all the td of the table and then compare the…
-
0
votes1
answer158
viewsA: How to echo the value of a variable from the query result
You can do this through a method called gambiarra. With this method you can call the function get_defined_vars() and it will return all variables declared. So you can search and replace the value…
-
1
votes1
answer753
viewsA: Get values from a json / object
To get street values, number, email, etc, you have to make a for each inside the other, for example: selectestado.change(function() { let estadoselecionado = $(this).val();…
-
2
votes1
answer26
viewsA: importing backup by Mariadb terminal
In the Mariadb you can use the source or simply \. to run a file .sql, for example: MariaDB> source file.sql MariaDB> \. file2.sql There are other ways to execute a script also: user@pc: mysql…
-
0
votes1
answer26
viewsA: I am entering an array in the database through a script I did but saves only the first and second digit
The problem is that you are creating several fields with the same name. When we click on campos, the value of the variable i it doesn’t change, it always continues as 1. This generates several…
-
0
votes1
answer62
viewsA: Javascript script error
The mistake is in getById. The correct is getElementById or querySelector("#id"). Complete Example: { let satual = 1; let smax = 3; let stmp = 3000; function troca() {…
javascriptanswered Valdeir Psr 10,804 -
1
votes9
answers166445
viewsA: How to hide/show a div in HTML?
It is also possible to use the method setProperty of the interface CSSStyleDeclaration, for example: document.querySelector("element").style.setProperty("display", "none", "important"); The last…
-
1
votes1
answer863
viewsA: How to take the value of a php variable and use it in the ajax request
Missing you add command echo to print the variable value. var price_prod1 =<?php $PriceProd1;?> The mistake is: var price_prod1 = <?php echo $PriceProd1; ?>…
-
0
votes3
answers219
viewsA: Duplicate jquery code without refreshing and deleting text in form inputs
Utilize insertAdjacentHTML, is simple and native. That way you don’t need to create numerous lines with createElement and do not use the unnecessary lines of the jQUery. With this function you just…
-
0
votes2
answers1361
viewsA: Insert content from an HTML file into a DIV - jQuery/Ajax
This happens because during the .load( URL ) you’re bringing some codes JavaScript repeated. This causes menu elements to keep adding more and more click events. These events are added so many…
-
0
votes2
answers939
viewsA: External Ajax URL Request
The mistake Status Code 401 happens when you make a request, but you are not allowed. Already the error cited in the comment of the previous reply: "Failed to load…
-
3
votes1
answer414
viewsA: Sql Injection in Stored Procedures
It is possible to perform sql injection in stored procedures? It depends on how you create these procedures, Anyway it is not safe to let the user inform any value. This is because the user can type…
-
0
votes1
answer138
viewsA: I can’t do Insert with array
Your query is invalid. $sql = "INSERT INTO locacao ( id_locacao, id_cliente, id_filme, data_locacao, observacao) VALUES ( NULL, '$select_clientes', '$filmeindice', '$datalocacao', '$observacao' ";…
-
0
votes1
answer482
viewsA: Insert data from multiple forms without refreshing with ajax php
Turns out you’re adding an element, dynamically. If you are dealing with the click of a button or sending the form before it actually gets added to the page, the function will fail. There are three…
-
2
votes1
answer29
viewsA: How to lynch a post categories on a Wordpress site
Turns out you’re not creating the element anchovy (or <a>). The correct is: <div> <?php foreach(get_the_category() as $category){ echo "<a…
-
0
votes1
answer58
viewsA: Autoplay videos when finished
The video only runs the second, because you are using the code: $("div[data-id='2']").attr("data-id-iframe"); This code will only capture the element data-id="2" and never the others. What you need…
-
4
votes1
answer228
viewsA: How not to repeat Wordpress loop posts
You don’t have to make a while, you can just pick up 3 posts from a finished category, and then just use $posts->the_post(); to capture the next, for example: <?php $mosaics = new WP_Query([…
-
3
votes2
answers59
viewsA: Help with logic - PHP
Your calculation is probably giving error because you are using the function pow (which is the high basis to the exponent). The correct is to do the same simple multiplication. $tp *…
phpanswered Valdeir Psr 10,804 -
1
votes1
answer213
viewsA: Validating date and CPF in the GUMP
In accordance with the documentation, there are two ways to create validations in GUMP. We can use the static method GUMP::add_validator or we can create our class and add the method…
-
0
votes1
answer169
viewsA: Convert Blob to String in Anglican
It turns out that the API FileReader loads the data in a way asynchronous, this means that the code will continue to be processed, even if a certain function is not yet complete, that is, the code…