Posts by Allan Andrade • 6,409 points
206 posts
-
1
votes2
answers12706
viewsA: How to know if a decimal number is even or odd?
As already explained by @jbueno, only integers can be classified as odd or even. For a number to be Even, it is necessary: Be a multiple integer number of two, that is, it can be written in 2x form;…
phpanswered Allan Andrade 6,409 -
1
votes1
answer491
viewsA: Tools and tests to improve a system’s security?
There are several tools. They test the application and the WEB server, regardless of the language in which it was developed. To test, simply enter the URL and type of tests. NOTE: The free versions…
-
4
votes3
answers1428
viewsQ: Error while breaking page for printing on Google Chrome
I have a page that prints tickets in 3 ways. Each ticket path is within one div with class ticket. After each route, I need to generate a page break. However, when using page-break-after: always; in…
-
1
votes2
answers196
viewsA: Javascript Checkbox All
The second W3C, the ID is a single attribute per page. The id attribute specifies a Unique id for an HTML element (the value must be Unique Within the HTML Document). Law more in: HTML id Attribute…
-
1
votes1
answer695
viewsQ: How to change the style of an element in an iframe from the parent page?
I use a component that generates a iframe accessing a remote page. Example: assuming that no iframe there is a table with some TDs with class destaque, want to put a red border on these…
-
2
votes3
answers89
viewsQ: Error calling a secondary method via CALLBACK: Uncaught Typeerror: Cannot read Property 'secondarily named' of Undefined
With Javascript (Ecmascript-6), when calling a method via callback, if this method uses another method the following error occurs: Uncaught Typeerror: Cannot read Property…
-
0
votes1
answer106
viewsQ: Encrypt critical data in the database
Thinking about security, and minimizing the problems in case someone disabled can have remote access to the database server, I thought to encrypt the critical data. Critical data examples (defined…
-
1
votes3
answers2939
viewsA: Identify repeated numeric characters in sequence
One option is to use the regular expression below and deny its output: 0{9}|1{9}|2{9}|3{9}|4{9}|5{9}|6{9}|7{9}|8{9}|9{9} Upshot: 111111111 // house 222222222 // house 333333333 // house…
regexanswered Allan Andrade 6,409 -
0
votes1
answer280
viewsA: javascript and jquery
Below is an example with the three requests working. Just run and test. $('#limparConcluidos').hide() // oculta o botão Limpar Concluídos $('#limparTudo').hide() $('#adicionar').click(() => {…
-
0
votes1
answer325
viewsA: Write JS to database with $_POST
First, to detect if the form was posted, use: if ($_SERVER['REQUEST_METHOD'] === 'POST'){ The name of your field in the form is mensagem and not txt_mensagem, so the line echo 'valor: ' .…
-
5
votes1
answer580
viewsA: Line break with <br> tag causes spacing in PDF generated
The tag <br/> does a line break and not a paragraph break, which should be done with <p>. Try the following code: <div style="clear:both;"> <span> <p align="justify"…
-
1
votes2
answers80
viewsA: how to add white space between strings
Just add the space in the string concatenation: var texto1 = "" + Enter.text! var texto2 = "" + Enter1.text! myLabel.text = texto1 = + " " + texto2
-
3
votes3
answers506
viewsA: Can you start with underline?
Yes. Yes, you can! According to the official PHP documentation about variables: "A valid variable name starts with a letter or underline" Examples: $4site = 'not yet'; // inválido; começa com um…
phpanswered Allan Andrade 6,409 -
1
votes2
answers815
viewsA: Error summing 2 php values
This is a repeated question. The decimals in PHP are separated by . (point) and no thousands separators. <?php function moedaPhp($str_num){ $resultado = str_replace('.', '', $str_num); // remove…
-
2
votes2
answers461
viewsA: Result automatic calculation javascript Asp.net mvc
You are using the event blur (when it loses focus) to call its function. You can use the eventu keyup (when you release the key) to call the function and have the result immediately while typing. In…
-
2
votes1
answer1287
viewsA: Which license to choose, MIT, Apache, GPL?
If you want to set free, I think MIT would be the freest of all. I suggest you read on: Which License Should I Use? MIT vs. Apache vs. GPL And about the GPL, there’s a very interesting question here…
licenseanswered Allan Andrade 6,409 -
1
votes2
answers55
viewsA: Check when writing to BD
The variable $erro, you just created but did not change the value of it at any time. For this reason, it will always record. However, it is not necessary to use this variable since you already set…
phpanswered Allan Andrade 6,409 -
7
votes1
answer257
viewsA: URL with uppercase letters
No. There’s no problem. But you should think about what will happen if a user tries to access http://exemplo.com.br/minha-pagina.php (all in lower case) ? Page not found or will open the same page?…
-
4
votes3
answers496
viewsA: php function to invert data
One way would be to use the substr: function inverteData($data) { if (count(explode("/", $data)) > 1) { return implode("-", array_reverse(explode("/", $data))); } elseif (count(explode("-",…
phpanswered Allan Andrade 6,409 -
2
votes1
answer3011
viewsA: html/css icon links
I believe you are referring to the use of Web Icon Fonts, implemented with CSS. Basically you have to include the CSS code for the Web Source, which will include the source files. HTML formatting…
-
2
votes2
answers222
viewsA: Button show div 1 and hide div 2 and vise versa
I made two options, run the codes below and see working. Option 1: using the property text button: function mostrar_abas(obj) { document.getElementById('div_aba1').style.display="none";…
-
0
votes1
answer108
viewsA: Remove a Foreign key from a production server?
If you already have a replica of the data, remove the column address_id, as you said yourself, it adds nothing but can cause confusion with programmers. Also, you already have the order table…
-
2
votes3
answers303
viewsA: Border Radius does not work within a CSS class
You must apply the border-radius in the li. But only in the first (.navbar li:first-of-type) and at last (.navbar li:last-of-type). See the FIDDLE updated and working:…
-
3
votes1
answer344
viewsA: Pick up only the days of the current month
To filter a range, you must use the between. The final date is CURDATE(), which is the current date of the Mysql server. The initial date you set in 01 and uses the current month and year and…
-
3
votes1
answer7674
viewsA: How to add php values?
The decimals in PHP are separated by . (point) and no thousands separators. Do so: <?php vlMateriaPrima = 3.05; $isumosMateriais = 0.25; $embalagem = 0.50; $custoDireto = vlMateriaPrima +…
phpanswered Allan Andrade 6,409 -
2
votes2
answers373
viewsA: How to add class in jQuery to a particular element?
Below is an example working for the url of this site’s snippets (http://stacksnippets.net/js) $(document).ready(function() { var pathname = location.pathname.replace('#', ''); $('.nav…
-
3
votes2
answers942
viewsA: How to run code with no open page in PHP
If using Linux, can be using the crontab: */12 * * * * /usr/bin/php -c /etc/php5/apache2/php.ini /var/www/html/seu_php.php Where: 12 = 60 seconds / 5 seconds (every 5 seconds) /usr/bin/php = path to…
-
1
votes2
answers365
viewsA: Add attribute to dynamically created object
With jQuery, you can do it using each, see an example below, where after execution, all elements with the class letters receive an attribute called data-id with the array value valores:…
-
7
votes1
answer1133
viewsA: Columns with equal names in a single query, mysql
You can do it like this: select contents.nome_igual as nome1, users.nome_igual as nome2 FROM users, contents
mysqlanswered Allan Andrade 6,409 -
2
votes1
answer2783
viewsA: CSS - Format a table
Run the code below and see working: .inANDout table { text-transform: uppercase; border-spacing: 0px; border-collapse: separate; margin: 0 auto; color: #595c62; font-size: 0.6em; font-family:…
-
1
votes1
answer3211
viewsA: Can you pass the function name as parameter?
Because they are first class objects, functions can be object properties or even arrays. If you have not defined who the function belongs to (object or other variable) it will belong to the object…
-
1
votes2
answers236
viewsA: Regex for different system subdomains or domain
You can try the following expression: /^((?!\b(app|sistema|local)\b)(.\w{2,3})*)(.\w{2,})(.\w{2,5})*.\w{2,3}$/igm See it working with any domain: http://refiddle.com/jt2a…
regexanswered Allan Andrade 6,409 -
2
votes1
answer1150
viewsA: How do I return to the same place on the page after clicking the back button?
Can do with history go.: javascript:history.go(-1);
-
1
votes2
answers11677
viewsA: Namespaces and Use when to use and for what purpose?
In accordance with the official PHP documentation about namespaces, is basically a way of encapsulating items. In practice, it serves to better organize your code, grouping classes and avoiding the…
-
1
votes2
answers229
viewsA: Store database links
You can use the example below: function getUrlAtual() { $url = ''; if (isset($_SERVER["HTTPS"])) { if ($_SERVER ["HTTPS"] == "on") { $url = 'https://'; } else { $url = 'http://'; } } else { $url =…
phpanswered Allan Andrade 6,409 -
10
votes2
answers1078
viewsQ: Increase timeout of dblib connection with PDO
On a connection to an external server (MS SQL SERVER), from another system with which I integrate some data, it is extremely slow, and with that the connection with the database gives error. How to…
-
0
votes1
answer645
viewsQ: How to limit the amount of impressions from an HTML document?
Precise limit the number of printouts of an HTML document. Currently if the file is generated (via PHP), record in the database a flag sts_impresso = 1, however, there are times when the user has…
-
0
votes3
answers210
viewsA: What’s the difference between var $var and public $var?
It was a way to declare an attribute with public. It is out of use since PHP version 5. Public attribute statement example using PHP version 4 or below (prefix var). <?php classe Caneta { var…
-
0
votes1
answer230
viewsA: Align image in the browser window footer
Place in the image CSS: { position: fixed !important; bottom: 0px; }
-
1
votes2
answers167
viewsA: Display div when clicking another, several with javascript
See an example with pure Javascript and no need to use ID. var x = document.getElementsByClassName("text"); x[0].style.display = "block"; // onde 0 é o índice. x[1].style.display = "block"; // onde…
javascriptanswered Allan Andrade 6,409 -
2
votes1
answer297
viewsA: I need to fill 2 fields using select
See below the code in operation: $('#frutas').change(function(){ $('#preco').val($('#frutas').val()); $('#nome').val($('#frutas option:selected').text()); $('#nome_preco').val($('#frutas…
-
0
votes1
answer815
viewsA: How to change tab(Pill) through navigation button?
There were two buttons with the same id (proximaAba). I added classes to simplify (the use of ID is not necessary for this operation). Also, I removed the class active of tab-pane current.…
-
3
votes1
answer42
viewsA: PHP error with Mysql
The mistake is because mysqli_query FALSE, so in error appears BOLEAN (that is not the type expected to fetch_assoc). The reason is that Caxias do Sul is a string and has it in quotes. It should…
-
1
votes1
answer146
viewsA: Do I need to use session_generate_id on all pages?
According to the PHP documentation on Sessions and security: Executing the session_regenerate_id() function could result in Dos attack, in the same way as use_strict_mode=On. However, Dos is still…
-
0
votes5
answers498
viewsA: Capture Enter in IE using jQuery
Use the e.keyCode: $(document).keypress(function(e) { var code = e.keyCode || e.which; if(code === 13) $('.button_ok').click(); });
-
8
votes6
answers7015
viewsA: How to get unique values in a Javascript array?
Using array.filter function array_unique(array){ return array.filter(function(el, index, arr) { return index == arr.indexOf(el); }); } var array = ['a', 'b', 'b', 'c', 'c']; console.log('Array…
-
2
votes3
answers792
viewsA: How do Apache (wamp) stop killing the session by itself?
Need to define the Session.cookie_lifetime and the probability of how much of the time the sessions expired will be collected. 0% = never. Session.cookie_lifetime specifies the lifetime of the…
-
5
votes1
answer1136
viewsA: How to block a range of Ips with php?
You can do it in many ways: Suppose you want to block the track: 90.25.. 1) Using strpos: if(strpos($_SERVER['REMOTE_ADDR'], "90.25") === 0)){ // se ip começa com 90.25 echo 'bloqueado'; exit; } 2)…
-
3
votes1
answer4540
viewsA: How to change the position of an html element with javascript?
You can do it using the method insertBefore to move to the beginning. Already to move to the end I used the karim79 Excellent Response insertAfter function I kept your original HTML markup, just…
-
6
votes1
answer178
viewsA: Syntax error when testing the query in phpmyadmin
phpMyAdmin does not accept PHP variables, in the example you used: $_base.avaliacoes. Try to accomplish: echo $sua_query; and test the result on phpMyAdmin Also, the dates are missing a single quote…