Posts by Bacco • 93,720 points
1,184 posts
-
7
votes2
answers4213
viewsA: Convert hour format in seconds
Using ready function whereas the strtotime PHP uses Posix/Unix time, a very simple way is this: $horario = "03:11:48"; $segundos = strtotime('1970-01-01 '.$horario.'UTC'); See working on IDEONE.…
-
5
votes1
answer94
viewsA: SYNTAX ERROR WHERE - PHP
First of all, PHP has nothing to do with the subject, this is an SQL error. The Where clause is one The Grouping then The Order comes later And the limit at the end If you have any questions when…
-
6
votes1
answer405
viewsA: Delete repeated words from an array and sort it
To remove repeated values: array_unique( $array ); To order: sort( array &$array ); And yet, if you want to ignore upper and lower case, and consider numbers by their total value and not by…
-
34
votes5
answers140931
viewsA: How to limit decimal numbers in Python?
Rounding If round: round(3.141592653589793, 2) Which is what happens when you do something like this. "%.2f" % 3.141592653589793 Truncating In this case it already needs more care, because the lack…
-
3
votes1
answer421
viewsA: SELECT Multiple Date Range in Mysql
If the DB is in date format, it is very simple (you can do with string too, but the performance is worse). Suppose you want the trainings that were in effect in the month 5 of 2017: SELECT DISTINCT…
-
6
votes4
answers4863
viewsA: How to pick the first word of a string with jquery?
A very simple way is to take the position of space with indexOf and extract with substring: primeira = texto.substring(0, texto.indexOf(" ")); Demonstration: var texto = "Teste de extração com…
-
11
votes1
answer1031
viewsA: How do I know if a point (x, y) is within the filled percentage of a pie chart?
You’re using a basic distance formula, which in practice simply tells you whether the point is in the circle or not. As it is already enough to determine if it is in the graph, all that remains is…
-
11
votes1
answer1377
viewsA: Select multiple CSS classes with wildcard
CSS3 solution As nowadays CSS3 is accepted by the overwhelming majority of browsers, you can do this with attribute selector: div[class^="col-md-"] { color:red } But BEWARE that the above example…
-
12
votes2
answers1351
viewsA: Error "expects Parameter 1 to be mysqli, string Given in"
Almost all mysqli functions use the "link" connection to the database as the first parameter. You do: $bd="admin_site"; And try to use $result = mysqli_query($bd, $sql); Since the first parameter…
-
3
votes1
answer339
viewsA: Help to understand SVG coordinates and sizing
First of all, it is good to understand that the SVG is practically an infinite frame to draw. You can draw on any positive or negative X and Y (as long as you do not exceed the numerical capacity of…
-
8
votes1
answer1004
viewsA: How to mount a SELECT to return the last status change of each id?
A simple way would be to do this: SELECT `id_fatura`, `status`, `data` FROM `status_faturas` GROUP BY `id_fatura` ORDER BY `data` DESC See working on SQL Fiddle. in this case the ORDER BY data DESC…
-
4
votes1
answer1432
viewsA: Accessing a shared directory through PHP, is it possible?
YES It’s possible and it’s in the manual: http://dk2.php.net/manual/en/function.fopen.php In particular, the title See Also: Supported Protocols and Wrappers that "link" to:…
-
3
votes3
answers1923
viewsA: Problem with image height
If you’re gonna be 100% tall width:100%, is height:100%, and the other sense, "self". If you want it to be larger than the frame (adjusting by width or height, depending on which is smaller) you…
-
5
votes1
answer288
viewsA: Problem with login system - array
This here will not practically generate the same hash that was written in DB: $seg_senha = password_hash($senha, PASSWORD_DEFAULT); and, among other things, that’s why the function is more secure…
-
5
votes1
answer774
viewsA: CRUD PHP No update, no error
In this block you link the variable $id to use in WHERE $stmt->bindParam(':nome', $nome); $stmt->bindParam(':nasc', $nascimento); $stmt->bindParam(':email', $email);…
-
8
votes1
answer451
viewsA: Delete Registration in Bd
You are testing $result, and has stored the result object in the query in the variable $sql $sql = mysqli_query("DELETE FROM images WHERE id='$id' "); ^^^^ if ($result) { ^^^^^^^ The nomenclature is…
-
7
votes2
answers1142
viewsA: Undefined index: PATH_INFO
If you want the equivalent of PATH_INFO to take the path of path, the solution is: $_SERVER["PHP_SELF"] The PATH_INFOonly brings the path, without query string and other information, then the…
-
3
votes1
answer36
viewsA: I have problems with this form to pass the given by PHP medium, but I can’t get the error
Basically a submit button is missing inside the form, if the button is outside the form or if you are only using a link, the data is not sent: <form action="form_handler.php" method="get"…
-
2
votes1
answer309
viewsA: mysqli: Couldn’t fetch mysqli_result
You’re trying to put a pointer to an open resource, not a result. It doesn’t work. Either you take the data and store it in an array, or better yet, open the connection and query where to use it. If…
-
6
votes2
answers798
viewsA: Mariadb ERROR: ERROR 1709 (HY000): Index column size Too large. The Maximum column size is 767 bytes
If you use utf8mb4, each character of a field CHAR or VARCHAR reserve 4 bytes, so your 200 characters may need up to 800 bytes. If you really need this index, or you need to narrow it down a bit...…
-
11
votes3
answers1336
viewsA: Why can’t I center image using text-align:center?
The problem is that you are trying to center the content of the image. To work the text-align:center, it would have to be applied to div where the image is. But it is also not the way. The best is…
-
30
votes2
answers310
viewsA: Go with a ";" at the beginning of the loop, which means
The for has 3 "parts": for ( executar antes de começar ; condição para executar ; executar ao fim da iteração ) You only need to fill in what you need. But you have to put the ; anyway. In this…
-
37
votes3
answers1426
viewsA: How does the HTTP protocol process requests?
First of all it is good to understand HTTP as a series of format conventions to be used over a common TCP connection. In principle it’s a protocol stateless where you basically send one text and get…
-
2
votes3
answers588
viewsA: Open as an administrator only the first time in Delphi.
As the use will be occasional, you can implement a C function to call by Delphi only when it needs lifting: #include "windows.h" SHELLEXECUTEINFO lpExecInfo; memset(&lpExecInfo, 0,…
-
3
votes1
answer36
viewsA: Replace string read from a file
You may have more problems with your code, but one obvious is this: Here you take a line and see if the Pattern is on that line: if (strpos($this->template->fgets(), $pattern) !== false) { //…
-
2
votes1
answer402
viewsA: I can’t link to css with relative path
Relative path is a problem in the described scenario. The 2 Urls mentioned are in fact in different paths, this "relative" would be which? http://local.dev/example http://local.dev/example/index In…
-
2
votes1
answer617
viewsA: Cropping image before uploading to server
You can include a field hidden in your form, and update it automatically: <input type="hidden" name="imagem" id="imagem" value=""> And in JS update the field automatically: if (result.src) {…
-
2
votes1
answer32
viewsA: Heritages of CSS
If you want everything to be div1 automatically behave as col-md12, only with CSS, no putting in HTML does not have an obvious way without repeating the instructions. What you can do is use tools…
-
0
votes2
answers102
viewsA: Download extensive file on website
As Victor Gomes solution, follows how was the final code: <div onclick="saveAs('<?php print base_url(); ?>web_files/uploads/radio/<?php echo $audios->audio; ?>')"> <button…
-
3
votes1
answer77
viewsA: Javascript possibly disturbing Mysql query
It would be the case to add the quotes in the template of query also: sql: `INSERT INTO ... VALUES (VALUES (${id}, '${temp}', ${activity[property][0].value})` ^-aspas-^ Since it is only a…
-
7
votes1
answer74
viewsA: Wanted to know how to create variables through for in javascript?
For this kind of thing, there are arrays, which are an indexed collection of data. Instead of doing variavel1, variavel2, you use a single variable, and an index of which data stored within it…
-
9
votes2
answers300
viewsA: Is it possible to do this effect with CSS?
In principle, there isn’t much to do with CSS in this case, and it would probably be better to have an animation or video Embedded. In order not to be completely unsolved, I set up an example of…
-
3
votes1
answer1147
viewsA: #1115 - Unknown Character Sep: 'utf8mb4'
According to the manual: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html The charset utf8mb4 was introduced in version 5.5.3. Thus, the remote version really cannot accept this…
-
3
votes2
answers80
viewsA: How do I use variables within this PHP + Mysqli code?
Typing error. You did not concatenate the values. Solution: $sql = "INSERT INTO cadastro (nome, sexo, dia, mes, ano) VALUES ('".$nome."','".$sexo."','".$dia."','".$mes."','".$ano."')"; It is worth…
-
5
votes1
answer655
viewsA: How to verify if a Trigger exists or not before creating it?
Consulting the triggers It depends on what you call "knowing if there is". Knowing if there is a name, or content? For a "peek" just the SHOW TRIGGERS Now, if you need anything more elaborate:…
-
6
votes1
answer1780
viewsA: Remove characters from a field in Mysql
Basically this: SELECT SUBSTR( campo, 5 ) AS restantes FROM tabela WHERE SUBSTR( campo, 1, 4 ) = '1170' The function SUBSTR (or SUBSTRING ) has that syntax: SUBSTR( valor, inicio [, quantidade] ) If…
-
2
votes1
answer512
viewsA: List data in separate columns
A simple way to divide one array in equal blocks (within the possible) is using the function array_chunk http://php.net/manual/en/function.array-chunk.php To split your list of cities into two…
-
3
votes2
answers520
viewsA: encoding php to mysql database
If you REALLY need to work with these two different encodings, it might be interesting to use these two functions, so as not to rely on connection conversions: To read from a Latin1 source: and use…
-
4
votes2
answers127
viewsA: Code only returns me the first row of the table referring to the patient ID
You have two options to take more than one datum in this context. One of them is to do this: while( $exames = $stm->fetch(PDO::FETCH_OBJ) ) { // este loop vai ser executado uma vez para cada…
-
6
votes1
answer264
viewsA: preg_match_all(): Delimiter must not be alphanumeric or backslash
You are reversing the parameters, a read on manual avoids these problems. preg_match ( string $pattern , string $subject ) The correct order would be this: preg_match(self::$Format,self::$Data) This…
-
1
votes1
answer48
viewsA: Meteor problem with remote control for Android
This is apparently a bug, and was recently reported on meteor: https://github.com/meteor/meteor/issues/7961 The problem is caused by spaces in the path used, the string after "Raphael" is…
-
6
votes1
answer178
viewsA: How to make width be text and not div
There are several ways, but I think for your CSS this is one of the simplest: display:inline-block; in the h3 to occupy only the necessary; text-align:center; in div so that the h3 stay centered.…
-
2
votes1
answer40
viewsA: Personal a problem that seems very silly about the PHP connection
That doesn’t make sense: $lista = mysqli_connect(BDconecta(), $query) or die("erro" . mysqli_connect_error()); You probably want this: $con = BDconecta() $lista = mysqli_query($con, $query) or…
-
38
votes8
answers3166
viewsA: Fewer moves from a horse to a given house in Chess
Given the size of the board, the shortest way to Dijkstra does not bring significant advantages over a Breadth-first search, which is simply a search that starts from the root, and then goes…
-
4
votes1
answer35
viewsA: Help with "Prism Syntax Highlighter" does not work right
The problem is that it is mixing the HTML that is to be displayed with the HTML that mounts the page. The solution is to do the escape internal HTML in this way: <pre title="HTML" data-codetype…
-
12
votes2
answers3911
viewsA: How to create local domains to test my websites and apps?
If you want a simple and ready solution for quick testing, go straight to the end of the question Do not fit door specifications on hosts, and there is no functionality related to redirects or…
-
5
votes3
answers460
viewsA: How do I create a directory through the Harbour language?
First of all, I don’t recommend creating temporary things in the program folder. OS usually already has a definition of temp for that reason. The function to create a directory is hb_DirCreate(…
-
4
votes3
answers922
viewsA: How to create a table (empty) from a selection of other tables?
To make "automatic": Create a condition that does not return records: CREATE TABLE tabela3 ( SELECT p.id_produto AS id_produto, p.nome_produto AS nome_produto, m.nome_marca AS nome_marca FROM…
-
4
votes2
answers159
viewsA: Inversion of array (positions)
The answer to the question comes down to one line: You cannot pass half the vector in your loop, but you are reversing and "deflecting" again as you pass through the middle. Just as an add-on,…
-
6
votes1
answer24684
viewsA: Select in two tables at the same time
What filters the result by a certain condition is the clause WHERE. If you want to select by name: SELECT autor.autor_nome, frase.frase_frases FROM autor INNER JOIN frase ON autor.autor_id =…