Posts by Bacco • 93,720 points
1,184 posts
-
4
votes1
answer49
viewsA: "Attempt to compare string with number" when comparing in Lua
The method io.read() returns a string (character string). You are comparing this string to the number 18. You cannot mix the two types (string with number) in the comparisons. To convert a string in…
-
2
votes2
answers26
viewsA: Join Mysql Tables with similar field names
When two columns have the same name in a Join (it is implicit, simply listing names, as your case or explicit using the word JOIN), you need to tell which table you are referring to when using the…
-
7
votes1
answer61
viewsA: Why in MOS 6502 the SBC subtracts 2 instead of 1 the first time?
SBC is "Subtract with Carry". Carry is what we call "Vai um" popularly, in a sum (or "lends one" in a subtraction). In decimal, follows an example of Carry: ₁ ← carry ₁ 17 17 17 somando o Carry + 05…
-
5
votes2
answers135
viewsA: Over or under age
As others have commented, the main error was rewriting the variable idade. Yet, as mentioned by @bfavaretto, it would be >= 18, and has a string comparison with integer commented by @Valdeirpsr,…
-
3
votes2
answers56
viewsA: Solved - Save more than one array in Mysql
A simple example of Pivot (exchange row by column), already generating SQL: $n = ['João', 'Maria', 'Afonso', 'Ana']; $p = ['Pai', 'Filha', 'Avô', 'Avó']; $d = ['01/01/980', '01/02/1999',…
-
4
votes1
answer33
viewsA: How to set a stylesheet for a widget without affecting your child widgets in Pyqt5?
You can name the widget and specify in the QSS: QMainWindow#janelaEspecial {background-image: url("./MyImage.png");} Everything you inherit from Object in Qt can be named with setObjectName…
-
3
votes1
answer127
viewsA: Like reading a JSON on Harbour?
Decoding with hb_JsonDecode The Harbour already has native function for this: hHash := hb_JsonDecode( cJson ) Example: hData := hb_JsonDecode( '{"Wallace":"Maxters","Score":100000}' ) ?…
-
3
votes1
answer42
viewsA: How to format a date in Harbour?
To change the default presentation used in ?, SAY, GET etc.: SET DATE german // Formatos pré definidos, legado SET DATE FORMAT TO dd/mm/yyyy // Formato customizável (pré processador) Set(…
-
1
votes1
answer23
viewsA: How to turn a link’s properties into a specific class or id?
No need to transform anything, just put the id or class in place of the tag. Example #cancel:hover /* não precisa por a tag "a" */ .external:visited /* e aqui, qualquer elemento com classe…
-
8
votes3
answers98
viewsA: Declaring PHP variables from the keys of an array
Native resource: the list This feature exists since PHP 4, is the list(). It’s that simple: list($variavel1, $variavel2, $variavel3) = $array; In newer Phps it accepts this simplified syntax, but it…
-
4
votes1
answer51
viewsA: How to make a condition that checks the variable type of a var
For type checking do not use the ==, and yes the is An example: if(varName is string) { // bloco } See working: IDEONE Now, you need to see if it makes sense in your case. Probably not! It probably…
-
3
votes5
answers1493
viewsA: How to create a function to validate time in PHP
It follows a very succinct "prototype", using the most basic of the basic, which is validation with if. (no need for Regex, conversions or even operations modifying string) function pareceHora($str)…
-
6
votes1
answer337
viewsA: Is it possible with CSS to make each letter of a word have a different color?
I consider it "appeal", but just to say that this path that began in the question would be a way: .two-colors { font-size: 160px; background: linear-gradient(to right, blue 20%, green 20%, green…
-
2
votes1
answer87
viewsA: Update salary attribute in MYSQL
This is just a protection set by the editor you are using (maybe Mysql Workbench?) It is worth noting that you are fiddling with two tables without spelling out the type of join used, the protection…
-
1
votes1
answer386
viewsA: Insert HTML code in iframe directly by Javascript
You are doing this: ifrm.setAttribute("src", bodycode); It turns out that src is the address of iframe, and not his html. If you want to specify a string as source, you have to modify the srcdoc:…
-
2
votes2
answers419
viewsA: Doubt with a countdown in JS and HTML
The problem is that every second you are initiating the val again. It gives the impression that the loop is not working, but in fact it "always works with the same value" See the difference…
-
3
votes3
answers835
viewsA: How to go through an array skipping some indices?
Complementing existing responses, depending on what you need, just reverse the logic. Exchange the i == j for i != j and do what you need inside the if: for (var i in vetor) { for (var j in vetor) {…
-
3
votes1
answer132
viewsA: Concatenate variables into C
There is how to do what you asked, but the result is probably not what you expect. To declare a structure in C, you have the struct (which is literally structure); To make two members point to the…
-
5
votes2
answers277
views -
3
votes1
answer60
viewsA: Problem with foreach() printing twice
The code is printing twice the amount as expected. Once in the echo $r['status'], and another in the echo $i; As you commented that you will use for formatting, you probably want it to print an echo…
-
4
votes1
answer264
viewsA: Isset in PHP ternary?
isset() is not used to test if a value is empty. The function is to check whether the variable is set or not. The empty() is to test whether a variable is "empty", and has the same property as the…
-
4
votes1
answer286
viewsA: I’m not able to send a POST to PHP by Javascript fetch
The $_POST of PHP presupposes chave=valor in the body, or a Multipart request. In the first case you need to use the type application/x-www-form-urlencoded, in the second multipart/form-data. You…
-
4
votes1
answer46
viewsA: Upside down widgets in Kivy
Can use F1 for settings, and has the configuration file as well. The item "Rotation" should be 0. It’s probably 180 in your case: Module: https://kivy.org/doc/stable/api-kivy.uix.settings.html…
-
2
votes1
answer81
viewsA: Change CSS with Javascript
Came close, basically wrapped in syntax error. style.widht is spelled wrong, is width. then just concatenate the value with variavel + "px" (the unit you find relevant to your case) Follows adjusted…
-
3
votes3
answers171
viewsA: Is there a native Javascript method that returns the sum of the elements of an Array ? How does array_sum() do in PHP
Another version for Guilherme to put in the benchmarks :D var i = arr.length; // use let se o ambiente for moderno var sum = 0; while (i--) sum += arr[i]; Following demonstration: var array_soma =…
javascriptanswered Bacco 93,720 -
9
votes3
answers108
viewsA: How to replace a string depending on page resolution
A little bit of CSS solves: Ant<span class="wideonly">erior</span> and then hide with an @media: @media only screen and (max-width: 800px) { .wideonly {display:none} } This @media will…
-
4
votes1
answer146
viewsA: Pyqt5 Changing the order of items added within the Qlistwidget
It is the expected behavior, according to the documentation. https://doc.qt.io/qt-5/qlistwidget.html If you don’t want an item at the end you should use insertItem and not addItem.…
-
3
votes1
answer76
viewsA: Loop repetition does not behave as expected
The program is acting as it should. finished_sandwiches is empty (= []), then the while finished_sandwiches has nothing to do. Now, if you trade the while for while sandwich_orders:, the thing…
-
10
votes3
answers17023
viewsA: Do while in python
No, but virtually every loop in most languages can be done in several ways. Pseudocode: do: fazCoisa() while condicaodesejadaparacontinuar Writing in Py: while True: fazCoisa() if not…
-
4
votes1
answer229
viewsA: How do I use a variable instead of the Array key?
The problem is that you are using ". key" literally, so you are referring to a "key" element:something that doesn’t exist. Use variable as index (no quotes) to solve: var objeto = [ { "id": 111111,…
-
3
votes2
answers53
viewsA: Random number generation in a function is always equal - C
Your code calls the function aleatorio() two times next. Within this function has a srand, which serves to initialize the sequence of random numbers (the "seed", or "Seed"). It occurs that very…
-
4
votes4
answers583
viewsA: Javascript function
Uncomplicated: Since no one posted the most basic code, here goes: function dobroDoProximo(atual){ return (atual+1)*2; } Demonstration: function dobroDoProximo(atual){ return (atual+1)*2; }…
javascriptanswered Bacco 93,720 -
2
votes3
answers73
viewsA: Key-value dictionary
First of all, one feature of the dictionary is to have A value for each different key. If you want two values, you need to use another structure (or use a structure instead of the simple value).…
-
7
votes2
answers52
viewsA: Why is if not comparing to html < entity?
Basically because you are confusing the content of the element with the HTML representation. The textual content (textContent) of span is < and not < (is what you used in the code), so the…
-
2
votes1
answer32
viewsA: Makefile linux - is it possible to restrict the compilation per machine?
You can set a variable on the correct machine, and make: ifndef MAQUINACORRETA $(error "Máquina errada") endif This way, the compilation will only work on the defined machine. This same logic can be…
-
5
votes2
answers105
viewsA: Grouping the largest ID per line does not take up correct values
The problem is that nothing guarantees in Mysql that columns without aggregation will return from the same row. Including, as noted by @Rbz in the comments, depending on configuration Mysql will…
-
8
votes1
answer528
viewsA: How do I use the same id more than once with getElementById()?
Solutions have many, but with the JS you are using, the ID is required (but has an alternative with class in the end). You can number the Ids: <li class="countdown-loop"><span…
-
2
votes1
answer1077
viewsA: Nodejs does not respect the OS daylight saving schedule
According to search of the author of the question, is a bug in the TZ table of Node.js. The solution is to modify the code temporarily until you can get the corrected version. Link:…
-
3
votes2
answers245
views -
5
votes2
answers154
viewsA: how to put php in html
I am assuming that you are just learning to use HEREDOC (and have NOWDOC as well). The fact is that the end of heredoc cannot be indented. the _END; has to be on the left bank. Of itself PHP manual:…
-
5
votes1
answer117
viewsA: How to avoid loading a favicon?
If there is nothing on the page that actually requests the "favicon", your browser will end up ordering a "on its own", which will not solve the problem. One way to avoid this behavior (which is not…
-
2
votes1
answer54
viewsA: How to search for id separated by "," correctly?
To find a comma-separated value inside a string there is the FIND_IN_SET. Applied to your case: SELECT encaminhamento FROM atendimento WHERE FIND_IN_SET( '12', encaminhamento ); Only the performance…
-
7
votes1
answer68
viewsA: What is the numbering next to the Unix commands?
The number in parentheses refers to section of the searched keyword/command. As the manual is divided into several parts (user commands, system calls, C library functions, devices, file formats and…
-
6
votes3
answers63
viewsA: Sort table by date
The problem is the use of the logical operator AND unduly: ORDER BY `transaction_DATE` AND `transaction_HOUR` DESC LIMIT 8 ^^^ If you want to sort by more than one column, separate by comma, always…
-
5
votes1
answer104
viewsA: How to create a triangular progress bar with borders?
Apart from the fact that the top edge is not exactly one pixel, you can do it with two gradients: .volume { width:70%;height:50px; border: 1px solid black; border-width:0 1px 1px 0;…
-
2
votes2
answers398
viewsA: Why does width and height not work in this case?
You are trying to put width on an inline element. According to the documentation, the property width is valid for all elements except for inline content not replaced, which happens to be exactly the…
-
5
votes2
answers930
viewsA: Random number between 0 and 8, except 5, in Javascript using Math.Random
Quick fix: var numero = Math.floor(Math.random()*8); return numero>4 ? numero+1 : numero Explanation: There are many ways to do it, but I’ll make a very simple one for your case. First, let’s…
-
4
votes1
answer100
viewsA: Error using PDO and Autoload
It has nothing to do with autoload, but the fact that you are trying to use a PDO in namespace Model\login When does namespace Model\login; one new qualquercoisa will be considered as…
-
4
votes2
answers1447
viewsA: How to give space between the value and margin of an input field?
Who defines the visual aspect is the stylesheet (CSS). The internal margin in a style sheet is defined by the property padding. Styles can be provided "inline", by external files or within a block…
-
2
votes2
answers48
viewsA: Problems in consulting with NOT IN
As commented by Mr Anderson, mysqli_fetch_assoc does not do what you are expecting, and the result you have obtained is absolutely correct (comes one at a time, and obviously is the first). Mr Sam’s…