Posts by Bacco • 93,720 points
1,184 posts
-
4
votes1
answer653
viewsA: How to delete multiple clients by checkbox?
Following possible correction: if( isset( $_POST['excluir'] ) && isset( $_POST['valor'] ) ) { require_once"conexao.php"; foreach($_POST['valor'] as $val){ mysqli_query($mysqli, "DELETE FROM…
-
3
votes2
answers1328
viewsA: Calling javascript function with null parameter
You can use the null as an argument: verificaCamposVazios(fsInformacaoCandidatoDados, null); But normally the lack of this should be no problem at all, because the omitted value will be null anyway.…
-
2
votes1
answer47
viewsA: Link misdirecting with htacess
If you just want it to work teste, can’t have the .*. RewriteRule ^teste$ teste.php If you want the URL to accept more things, separated by bars, you can use it like this: RewriteRule ^teste(/.*)*$…
-
7
votes2
answers868
viewsA: How do I display a message if register found and if not found?
Basically that’s it: or die ("Não foi possível realizar a consulta ao banco de dados"); if( mysql_num_rows($ridfoto2) == 0 ) { echo 'Não veio nada'; } else { while($rowfoto2 =…
-
2
votes1
answer215
viewsA: Assemble news by grouping results by user class
One of the things is to add the field you want to sort in ORDER BY: SELECT a.id_salapostagem, a.titulo, a.mensagem, a.data_lancamento, b.descricao FROM salapostagem a INNER JOIN usuariotipo b on…
-
3
votes2
answers32
viewsA: How to expand an array_shift beyond the amount of indexes?
Using an array_shift You can rotate the array thus: array_push( $cores, array_shift($cores) ); Applied to the code: if ( $empr->have_posts() ) { while ( $empr->have_posts() ) {…
-
2
votes1
answer331
viewsA: MVC C# How to force SSL - too_many_redirects
Response based on the comment that mentions using Cloudflare How you use Cloudflare, the way to check the protocol is to refer to the header HTTP_X_FORWARDED_PROTO: protected void…
-
21
votes2
answers669
viewsA: What are the advantages of using associative arrays?
According to the manual, the arrays PHP associatives are "ordered maps". There are a multitude of situations in which they can be useful. Loops The premise is not correct, you can use in a…
-
13
votes2
answers1551
viewsA: What is the difference between repeat and while on the moon?
Basically the repeat is equivalent to do ... while of other languages. In the while, you are giving the condition to enter the loop. If the condition is false, the operations performed within the…
-
8
votes2
answers5915
viewsA: How to leave a span in the center of a div both vertically and horizontally
Usually, when we don’t have the exact measure of span, we can use the following technique: First, let the div with position:relative, so we can leave the span in absolute in relation to this. Then…
-
4
votes2
answers1244
viewsA: Upload image Php Bootstrap File Input (Undefined offset)
Here I included a isset(), to see if there was shipping: $uploads_dir = 'images/'; $extok = array( 'jpg', 'jpeg', 'gif', 'png', 'bmp' ); $img = array(); if( isset( $_FILES['files'] ) ) { $fdata =…
-
5
votes2
answers758
viewsA: PHP Mysql avoid database registration in uppercase letters
I usually use a margin of tolerance. You can do something about that: function porcentagem_maiusculas( $string ) { $count = 0; $len = mb_strlen( $string ); for( $i = $len - 1; $i >=0 ; --$i ) {…
-
3
votes2
answers148
views -
4
votes2
answers880
viewsA: Run command for each file in a directory in MS-DOS
One possibility is to use FOR: FOR %a IN (*) DO echo %a The above syntax is to execute directly in CMD. To use in . bat use two %: FOR %%a IN (*) DO echo %%a Replace the echo by the desired command,…
-
8
votes2
answers322
viewsA: Why can’t I use $this within a Static class?
The $this represents the instance of a class. You should not use it for static methods, simply because there is no concept of instance in them. In fact, the reason to use a static method is the…
-
3
votes1
answer63
viewsA: How I select several values from the same table
If you want each rate come in a separate line, that’s enough: SELECT rate, COUNT(*) AS row_count FROM tb_comment WHERE id_mark=:post_id GROUP BY rate Note that I changed the AS rate for AS rate_sum,…
-
14
votes2
answers4638
viewsA: Fibonacci sequence
One problem I found was your IF not skip the first 2 numbers, see the subtle difference: $sequence = array(); for ( $i = 1; $i <= 100 ; $i++) { if ($i <= 2) { // Ou começa $i de 0, ou usa…
-
3
votes1
answer353
viewsA: Delete in multiple POSTS with checkbox
Basically your form may have this structure: <form method="post"> <input type="checkbox" name="deletar[]" value="1" />Banana<br> <input type="checkbox" name="deletar[]"…
-
1
votes2
answers90
viewsA: Destroy Session when changing profile on mobile and affect pc
Follow a refactoring of the code, and below an explanation of the changes and their reasons: $levelLogged = 0; if( isset($_SESSION['userId'] ) { $query = 'SELECT * from users WHERE id=:userId'; try…
-
7
votes3
answers399
viewsA: while list 4 in 4 result within div
This version has logic similar to the author’s attempt and @Guilherme’s response, using the %. The difference is that the module calculation was done in 2 separate lines, to avoid the repetition of…
-
2
votes2
answers3439
viewsA: Warning: array_push() expects Parameter 1 to be array, null Given in
Jeferson already gave a solution to the problem, but I’m complementing it to comment more specifically on the initial cause of the problem. Note in the method definition: public function…
-
3
votes1
answer34
viewsA: Invalid Configuration when saving Synonyms in Cloudsearch via PHP SDK
I think it’s the lack of aliases (or alternatively a groups). Description in documentation: { "groups": [["tool box", "toolbox"], ["band saw", "bandsaw"]], "aliases": { "workbench": ["work bench"]}…
-
7
votes2
answers369
viewsA: How to add everything in MYSQL
Mysql has the function SUM( ), suitable for your need. Here I am grouping by id_user, but can be by another field, depends on the goal: SELECT SUM(rate) AS total GROUP BY id_user If you want to add…
-
1
votes1
answer434
viewsA: Generating valid Php Array for json conversion
Follow its refactored code to simplify testing and eliminate possible points of failure. One of the possibilities for the json_encode fail is to receive data with non-ASCII characters that are not…
-
4
votes1
answer451
viewsA: Index limit with LIMIT
Often the query Planner realizes that the performance of a sequential disk reading comes out "cheaper" for the system than by consulting the index and taking random readings. With no index, DB can…
-
3
votes1
answer667
viewsA: Keep database connection open in PHP
It’s terrible, because if you have a thousand users browsing the site, you will have a thousand connections open at the same time, when in normal use the connection would only be open for…
-
8
votes1
answer295
viewsA: Virus decryption - vbscript
It’s basically a substitution game. I do not intend to talk about the whole function, otherwise the answer will become immense (I can change my mind later), but follow the main steps to give an…
-
4
votes1
answer201
viewsA: How to group subtraction of equal fields in Mysql?
The function IF can be useful because you solve with only one query: SELECT SUM( IF( tipo='1', valor, -valor ) ) AS total FROM conta_corrente_funcionario GROUP BY idFuncionario In this way,…
-
2
votes3
answers9055
viewsA: How to change the text of a button when submitting a form?
For jQuery above 1.6, it is recommended to use prop in place of attr. Follow an example that in addition to changing the text, disables the button to avoid more than one upload next:…
-
7
votes4
answers268
viewsA: BETWEEN demands arguments in ascending order? Why?
First of all, I understand that there is some logical motivation in the question. If something is between 1 and 3, in principle it is between 3 and 1. What is not true if it is a trade that opens…
-
7
votes6
answers10518
viewsA: Difference between php <?php tags and <?=
The syntax <?= ?> is a shortcut to this: <?php echo ; ?> Before PHP 5.4 the option short tags should be enabled to use this shortcut. In PHP 5.4 this option is always available. So much…
-
10
votes2
answers210
viewsA: In PHP what does this <?= ? > tag represent?
This syntax is a shortcut to this: <?php echo ; ?> Before PHP 5.4 the option short tags should be enabled to use this shortcut. In PHP 5.4 this option is always available. So much so that this…
-
3
votes2
answers59
viewsA: What php code do I use to know if the data is being received from a given form?
In addition to the proper solution posted by @rray, you can use the Submit fields to differentiate the Forms: <form method="post" action=""> CPF: <input type="text" name="cpf"…
-
2
votes2
answers541
viewsA: Can I use Get or Post to read an Array?
The simplest way is to take it directly by the name of array: <form method='GET'> <input type="hidden" name="idArray[]" value="1" /> <input type="hidden" name="idArray[]" value="2"…
-
41
votes2
answers27855
viewsA: What do Rewritecond and Rewriterule mean in a . htaccess file?
Rewritecond You must use the directive RewriteCond to add conditions to apply or not redirect. For example: # Redirect when we have a single parameter RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond…
-
4
votes1
answer637
viewsA: How to link a specific div from another PHP page
The page loads without style because of the extra bar in the address: <a href="index.php/#agency-split">Vídeo</a> ^----- esta barra não deveria estar aqui You probably have style sheets…
-
11
votes2
answers484
viewsA: How to show custom page for inaccessible folders in Windows?
First of all I thought it was a little strange when you said it: Created c: wamp www denyfolderwindows ... I created a . htaccess file within c: wamp www myfolder ... If it really is like this, the…
-
7
votes2
answers521
viewsA: How to use unit of time less than milliseconds in a setInterval or setTimeout
The question has been answered here, and already received my +1. I will complement with this answer, which refers to the real problem, which was not initially posted in the body of the question. For…
-
2
votes1
answer80
viewsA: Count records only if larger than the current datetime, with Count()
I would suggest using this: SUM( IF( a.expira > 1449365367, 1, 0 ) ) Explanation: The SUM serves to add values of a field, and based on this we create a special "field" that will give us 1 for…
-
15
votes1
answer2002
viewsA: Consulting multiple Cnpjs situation in the IRS
One possibility for those who have a digital certificate (e-CNPJ, Nfe etc) is to use the system provided by SEFAZ as part of the Nfe structure: CadConsultaCadastro2 I will take as an example the…
language-independentanswered Bacco 93,720 -
9
votes2
answers3496
viewsA: How to run a file with PHP?
As I had commented as soon as the question was posted, you can use the function exec(): exec( 'caminho/do/executavel', [array &$retorno], [ int &$status_erro ] ); This function works well on…
-
20
votes5
answers15911
viewsA: How to make a circle in CSS without Border-Radius 100%?
How about just using the background of the CSS? background: radial-gradient(ellipse at center,#f00 0%,#f00 0%,#f00 67%,rgba(0,0,0,0) 70%); See in action: #circulo1 { background:…
-
6
votes2
answers853
viewsA: Make shapes with CSS
Just one line of CSS, using gradient instead of solid color: background: linear-gradient(170deg, #ffffff 0%,#fff 49.8%,#000 50.2%,#000 100%); Here is a simple example, with prefix for several…
-
3
votes1
answer1867
viewsA: explode() right on Mysql
I’m waiting for the community to decide to see if it’s a duplicate of what @rray recommended. If the values are separated by a comma and you want to find one of them: SELECT * WHERE FIND_IN_SET(…
-
9
votes2
answers203
viewsA: What does the "/" bar on the border-Radius mean?
The bar serves to specify two different radii for the curvature. border-radius: 40px / 20px; horizontal --^ ^-- vertical The same syntax can be used to specify the four corners. Note the difference…
-
2
votes2
answers1652
viewsA: SQL Server: how to create range of values based on a column with monetary values
Here is a solution that groups by quantities of 1.00 to 9.99, 10.00 to 99.99, 100.00 to 999.99 and so on: SELECT POWER( 10, FLOOR( LOG10( valor ) + 1 ) ) - .01 AS Teto, COUNT(*) AS Quantidade FROM…
-
4
votes2
answers916
viewsA: CSS animation: control which element respects the screen size limits
The initial solution was to put a container to limit the action of the object: @keyframes anima{ 0%{ left: 0; } 50%{ left: 100%;} 100%{ left: 0; } } #container { width:100%; box-sizing:border-box;…
-
3
votes2
answers369
viewsA: Field allowing only an exact amount of data
To fill an INT value with zeros on the left: ALTER TABLE cartoes CHANGE COLUMN `os_4_ultimos_digitos` `os_4_ultimos_digitos` INT(4) ZEROFILL To add a column already with this feature: ALTER TABLE…
-
9
votes2
answers1119
viewsA: How to put the background effect fixed and on the whole screen?
With jQuery I don’t see much sense, but with CSS it would be enough: body, html { margin:0; padding:0; border: none; } body { background: url(http://i.stack.imgur.com/o7AFv.jpg) no-repeat center…
-
8
votes3
answers1244
viewsA: How to make a NOT IN SQL?
I imagine the problem is that the id cannot be both the commander and the co-pilot, so this particular condition is if the ID is from one OR another: SELECT pl.id FROM Piloto pl, Voo v, Rota r WHERE…