Posts by Bacco • 93,720 points
1,184 posts
-
2
votes1
answer71
viewsA: Help me make a stop!
You are not passing $linhas for the function. That should solve: function adcionar_linha( $linha, $linhas ) { $linhas .= $linha."%0D%0A"; return $linhas; } function criar_paste( $linhas ) { $curl_ch…
-
7
votes4
answers3023
viewsA: Rand between numbers with comma
First of all, @Maniero’s answer already gives the solution that I understand to be the most technically correct for the problem, even more considering that the question asks solution in C++. I…
-
2
votes3
answers522
viewsA: How to put variables in datetime (PHP)
William’s answer already explains the basics well, and to complement, I leave here a path that seems technically appropriate, since you have the variables separately: $date = new DateTime();…
-
4
votes1
answer930
viewsA: How to protect my videos
As you said you use Apache, it has a very interesting tool to send files under PHP control, but at the same time without needing PHP to generate communication, which is the module x-sendfile.…
-
14
votes2
answers28807
viewsA: How to insert a first line indent with css?
In pure CSS just use the text-indent: .recuo { text-indent:4em } <p class="text-info recuo"> Suspendisse nec tincidunt nulla. Aliquam et urna magna. Suspendisse et tortor libero. Mauris risus…
-
3
votes2
answers308
viewsA: Bit array in c doubt
In an Array of bytes, each of them occupies a memory position. Each byte has 8 bits. That is, in each position of the array we have eight bits, so we have to have a way to get each one individually.…
-
11
votes2
answers18476
viewsA: optimized way to recover last mysql ID
None of these alternatives serves to recover the last ID. Your code is to recover the Highest ID. Usually the last and the largest coincide, but it is not an absolute truth. To know the last ID…
-
6
votes1
answer295
viewsA: Error using a function within a PHP array
The problem is that you are trying to create an array with a non-literal value It would probably be better to use a class member instead of trying to create a function-dependent value within the…
-
1
votes1
answer112
viewsA: Restricting Access to php Page with Port
The first thing is to make sure that your web server is set to answer on the port you wish to have the login. As you commented that you use Apache, the relevant configuration is here:…
-
4
votes2
answers109
viewsA: Why is 8 showing up and not the number referring to i?
As @Sergio mentioned, the problem is similar to this question: How to use the current value of a variable in a more internal function? However, perhaps the solutions there are not suitable for your…
-
3
votes1
answer82
viewsA: Break line after <img> tag with Regex
Follow the Regex: preg_replace( '/(<\s*img.*>)/U', "$1<br>\n", $string ); See working on IDEONE. I’m only worried about helping you make the site complicated for nothing, because the…
-
5
votes1
answer54
viewsA: Remove WP tag with PHP
Using Regex, this is one of the simplest ways: preg_replace('/\[\/?caption.*\]/U', '', $string ) Basically she changes everything inside [ ] and starts with caption or /caption. The modifier /U…
-
3
votes1
answer288
viewsA: BETWEEN with DATETIME field
Since you didn’t post the PHP code, follow the initial setting of the query only: SELECT u.Nome, u.Email, cp.DataSolicitacao, cp.CodigoPromo, cp.IdTransacao FROM cartao_pedidos AS cp INNER JOIN…
-
0
votes2
answers680
viewsA: Align Menu Items Vertically
Using vertical-align: Missed the vertical-align in your code. By default, inline-block is aligned by baseline. See with vertical-align:middle: #menu{ background: #535454; width: 100%; overflow:…
-
6
votes3
answers195
viewsA: Can you do a + or - value operation in a Mysql query?
Using the ABS, becomes very simple: SELECT campos FROM tabela WHERE ABS( valor - 5 ) < .5 │ │ valor buscado 5 ───┘ │ tolerancia 0,5 por exemplo (ajuste como quiser) ──┘ See working on SQL Fiddle.…
-
6
votes1
answer117
viewsA: Date and Time and Weekend
First, you can simplify your line like this: $timeStamp = time() + 300; This avoids a lot of internal operations and gives the same result. time returns the value in seconds, then just add 5 * 60…
-
4
votes4
answers1133
viewsA: Return a sum in separate rows in mysql
The IF function: Mysql already has its own tool for conditional situations. It is the function IF: IF( expressão de teste, valor se verdadeiro, valor se falso ) Applying to the case of the question:…
-
4
votes2
answers90
viewsA: Regular expression for number
I know you asked for one Regex, and @rray posted the solution that does exactly what you asked (and already took my +1). Anyway I think it’s important to comment that PHP already has a solution made…
-
4
votes2
answers15417
viewsA: How to add the diagonal of a matrix in C?
Your code had basically two problems. Like @Luiz Vieira mentioned, you weren’t holding the value of x in the matrix. Also, as you yourself noticed, it had an unnecessary loop making the sum. To make…
-
2
votes1
answer7998
viewsA: ERROR 1241 (21000): Operand should contain 1 column(s)
Basically the problem is that in this part, you are comparing a value with a group, and the equality operator only accepts one field or value on each side: work_students.student_qrcode =…
-
1
votes1
answer261
viewsA: Direct sum in PHP
A simple example: <?php $total = 0; while($row = mysql_fetch_object($trabalho)) { $total += $row->valor; echo…
-
3
votes1
answer101
viewsA: Redirect value from time function to file
According to the manual of time The time command runs the specified program command with the Given Arguments. When command finishes, time Writes a message to standard error Giving timing statistics…
-
3
votes2
answers1258
viewsA: Count values with specific data in MYSQL
Follows a query that counts the assets, the non-active and the total in one query, returning everything in the same line, to simplify the use in PHP: (line breaks for easy reading) SELECT SUM( IF(…
-
4
votes1
answer374
viewsA: How to decode html entities (Entity)?
To remove entities of string: Just use the function html_entity_decode $dec = html_entity_decode( 'Recebido por estagiários do projeto Memória' ); If you need to specify a…
-
2
votes1
answer170
viewsA: Do em and rem use html or body tags as a reference?
The rem is based on the html, if the document is an HTML According to the W3C: rem Unit: Equal to the computed value of font-size on the root element. Meaning: unit rem: Equal to the computed value…
-
4
votes1
answer1432
viewsA: How to transform a while structure into for? And vice versa?
Since you did not define the language in the question, follow a "generic" example that iterates from 1 to 10: for( i = 1; i <= 10; i++ ) { ... conteudo ... } Equivalent with while: i = 1; while(…
-
5
votes1
answer3273
viewsA: Insert data into mysql, in a timestamp field
Two syntaxes: INSERT INTO meubanco.minhatabela ( duracao ) VALUES ( '2016-04-29 00:00:00' ) Or INSERT INTO meubanco.minhatabela SET duracao = '2016-04-29 00:00:00' (I hope your field is duracao, and…
-
4
votes1
answer89
viewsA: If fclose closes a file, how do you close an open file with the Splfileobject object?
Just set it to null $file = new SplFileObject('file.txt', 'r'); $file = null; In general objects has a Cleanup in the destructor, the fact of setting the variable to null already does what is needed…
-
0
votes2
answers2955
viewsA: Capture field value by its ID and turn into a variable
If you want to take the content of an element in JS, just this: var teste = document.getElementById('exemplo').innerText; But it’s worth saying that it won’t work with a td loose, without the table…
-
6
votes4
answers2497
viewsA: How to dynamically change the color of the text based on the background color?
Using mix-blend-mode: Acceptance of this parameter is not one of the greatest, but for now I believe to be the only reasonable alternative with pure CSS: .tr1 { background-color: white; } .tr2 {…
-
13
votes5
answers10575
viewsA: Subtraction of hours in php
Note: I didn’t remember this one and ended up answering a duplicate with a solution even more elegant than the one here (and obviously without using Datetime, which is more important). For those who…
-
4
votes3
answers1007
viewsA: Parity test in C
This is a suitable task for bit operators: #include <stdio.h> int checkParity(unsigned char a) { int odd = 0; while( a ) { odd ^= a & 1; a >>= 1; } return odd; } // teste, igual o do…
-
4
votes1
answer54
viewsA: Link is not active
Has a isset left in your code, and the result of isset is always 1 if the variable exists. See the difference: switch( $_GET['k'] ){ case '1' : $ativo1 = 'class="uk-active"'; break; case '2' :…
-
3
votes2
answers68
viewsA: Print a gradual number of characters
I understand that as it is an exercise, the @Diegof answer is the most correct for the question. Just as a reference, you get a version using str_repeat, most suitable if it is for an actual…
-
38
votes1
answer29792
viewsA: Set up Cronjob to run every 5 minutes, when it’s between 5 to 20 hours
The */5 means "any minute, but every five". Depending on the implementation, that’s enough */5 5-20 * * * php ~/pasta/para/app/artisan queue:work Syntax of crontab: * * * * * caminho/comando │ │ │ │…
-
6
votes1
answer1191
viewsA: Create circle around numbers with JS and CSS
You can’t do this with just CSS (at least not without violent antics). You need at least something like this: <div class="circulos"> <i>1</i> <i>2</i> ... </div>…
-
2
votes1
answer98
viewsA: Error checking result of variables with Else and if
Two things. First you are making a number of comparisons separate. According to what the ideal would be to check if it is empty, and use the else to go eliminating conditions: if ( empty( $login )…
-
5
votes2
answers1625
viewsA: Serriled source Firefox
Understanding the difference between Antialies traditional for the Cleartype See your enlarged image: Note that the image on the right has colored pixels. As the LCD is not formed by pixels of all…
-
8
votes2
answers1263
viewsA: How to customize the side edges of a DIV?
Pseudo-elements are a quick and practical solution: .borda { position:relative; float:left; padding:0 20px; /* espaço nas laterais */ font-size:20px; } .borda:before,.borda:after { content:'';…
-
16
votes2
answers392
viewsA: How to make lines intersecting on an edge, with CSS?
Follows a solution that uses a div to cross-border using pseudo-elements: .borda { display:inline-block; position:relative; } .borda:before { content:''; display:block; position:absolute;…
-
3
votes1
answer1085
viewsA: UPDATE with different conditions in the same query
Can use a IF() UPDATE tabela SET ativo = 1, nivel = IF( nome='jose', 2, 1 ) WHERE nome IN ( 'jose', 'maria', 'joao' ); I find it interesting as knowledge, but in practice do not create this type of…
-
2
votes2
answers2062
viewsA: Find next multiple of 10 of a number in php
Basically this: round( $a + 4, -1 ); Applied to your code: $a = 142; echo round( $a + 4, -1 ); See working on IDEONE. Round serves for rounding of numbers in n decimal places, but if you use…
-
15
votes1
answer153
viewsA: Entry page of this genus
Since you haven’t given many details of the problem or the difficult part of the layout, follow a CSS and HTML with just about everything you might need: (Click Run, and then "WHOLE PAGE" to view…
-
2
votes2
answers318
viewsA: Change background-position with Javascript
With jQuery it’s simple: $('#anim').animate({'background-position-x': '100%'},8000,'easeOutCubic'); body,html,div { margin:0; padding:0; width:100%; height:100%; position:relative; } #anim {…
-
3
votes1
answer4199
viewsA: How to stop a loop using the input provided by the user?
One of the first things to consider is adding the pair to the variable dic only after the break, After all, if you’re going to use 9999 as an output, it’s not for 9999 enter the dictionary, mainly…
-
11
votes2
answers4322
viewsA: How to make decision structure to change color in a bat?
Important to note that to change the color individually per line, you need some helper program. The rest is basically that: //salvar como cping.bat ou coisa do tipo //uso: cping <IP> @ECHO off…
-
7
votes1
answer394
viewsA: Problem in UTF-8 characters
PHP already has specific functions to handle URL, which are urlencode() and urldecode(). Note that they already solve the exchange of + by space, as this is part of the encoding URL used by mime…
-
5
votes1
answer2448
viewsA: Mysql display the sum field with null value
The COALESCE That’s what it’s good for: CRE.VALOR AS CREDITO, DEB.VALOR AS DEBITO, ( COALESCE( CRE.VALOR, 0 ) + COALESCE( DEB.VALOR, 0 ) ) AS SOMA The syntax is: COALESCE( v1, v2, v3, ... )…
-
2
votes4
answers2812
viewsA: Sending email by PHP does not show accents correctly
How do you have these lines: $msg_tipo = $_POST["msg_tipo"]; $cabecalho .= "\nContent-Type: $msg_tipo"; is a matter of ensuring that the variable $msg_tipo has the correct charset, either coming…
-
8
votes1
answer2606
viewsA: Insert a loop inside another loop
Following version with intercalation, after the question is edited: for(var i=0; i<10; i++){ document.body.innerHTML += i + String.fromCharCode(i+64); } It’s the same as: for(var i=0; i<10;…