Posts by Andrei Coelho • 6,196 points
249 posts
-
2
votes2
answers299
viewsA: Regex - Selecting the first occurrence of a sequence of a number block
That REGEX .*([0-9]{6}).* in addition to bringing the last number within the group, as detailed in the @hkotsubo reply, your counter (.*) brings as much of any character as possible that is before…
-
1
votes2
answers79
viewsA: Array php not displaying key with same value
I would do so: (code is commented) // ao chegar nesse valor de consultas agendada por horário é retirado o horário do array hours $chooseNumber = 3; $count = array_count_values( $schedule );…
-
1
votes1
answer115
viewsA: Java.lang.Nullpointerexception because of a list
Your code has 2 problems. 1 - You create a new Account object within a loop while that is never used. while(check == false) { ... Conta conta = new Conta(nome, senha, numeroDaConta, saldo);…
javaanswered Andrei Coelho 6,196 -
1
votes2
answers186
viewsA: Help to pick up response values on Android with Retrofit
From what I understand, yours json is the problem for the retrofit: [ // <-- problema { "id_cliente":"31", "0":"31", "cliente":"Cliente teste", "1":"Cliente teste", "data_hora":"2018-12-17…
-
3
votes1
answer93
viewsA: What exactly is the Datetime::createFromImmutable() method for?
Attending to the request, the method will serve for you to create an object DateTime from an object DateTimeImmutable. $immutable = new DateTimeImmutable(); // objeto imutável $mutable =…
-
1
votes1
answer32
viewsA: Disable paging link if already on the corresponding page
Try it like this: for($i=$pc;$i<=$pc+5;$i++) { if($i==$tp) { echo '<li><a href="?pag='.$i; if($i==$pc) { echo '" class="disabled">'.$i; // <-- insere a classe disabled } else {…
phpanswered Andrei Coelho 6,196 -
1
votes2
answers60
viewsA: Error in class object generation
You need to convert the string coming from json to int. It is not specified, but by the comment in the code, understood that the value is a string: "idClientesT":"1" // <-- com aspas For this,…
-
2
votes2
answers396
viewsA: Using REGEX in PHP to capture any number that is not within single quotes
I created a REGEX that I believe meets your need: (?<=\s|^)(\d+[.,]{1}\d+|\d+)+(?=\s|$) Take a test: 12,2 12.1021 14 '51' '1' '23323' 12 The only rule for it to work is that the numbers are…
-
1
votes2
answers441
viewsA: Problems Saving Sqlite Data - Android
The problem is in the builder of FormularioHelper which is used in Activity: public boolean onOptionsItemSelected(MenuItem item) { FormularioHelper helper = new FormularioHelper(this); // <--…
-
2
votes1
answer155
viewsA: Success message with ajax boostrap 4 validation
The problem, as far as I’m concerned, is that you’re putting the preventDefault() within the if. When your code enters the else the preventDefault() is not triggered, changing the current state and…
-
0
votes3
answers125
viewsA: How to limit extensions that can be saved? (PHP)
From what I noticed you want to analyze an IMAGE. Soon, you can use the getimagesize() to know if it is really an image. For it will return false if it is any other file. Then you can implement the…
phpanswered Andrei Coelho 6,196 -
1
votes1
answer160
viewsA: Failed to use Retrofit library in Android Studio
The problem is that you are using the library annotation wrong. Actually you are not even using it. The error is as follows: @Path can only be used with relative url on @GET First you need to…
-
1
votes2
answers118
viewsA: What is the difference between getRating() and getProgress()?
It’s the other way around: The getProgress() returns an integer value, while the getRating() returns a float. The difference Although the RatingBar be a subclass of ProgressBar the getProgress is…
-
0
votes2
answers69
viewsA: Android Studio does not recognize the getRating() method
My answer is based on the codes you posted. Perhaps, the solution I will present is not the most appropriate. Analyzing You have an attribute of FormularioHelper of the kind EditText called…
-
0
votes1
answer215
viewsA: Can I get the text from the HTTP request?
You can recover all this information in PHP. It is not available in a file as stated by "please delete my account". In the image, you have a request via POST, the headers and in the body all the…
-
1
votes1
answer61
viewsA: How to identify equal classes in numerical order with jQuery?
You can pick up the content through the index(): $(document).ready(function(){ $(".mudar").click(function(){ var indice = $(this).index(); $("#download").attr("href", "https://file"+indice+".zip");…
jqueryanswered Andrei Coelho 6,196 -
2
votes1
answer125
viewsA: PHP - Take a value and modify the date day
A simple date() should solve your problem: $hoje = date("d/m/Y"); $diaDoUsuario = 30; $proximaData = $diaDoUsuario."/".date("m/Y"); if($proximaData == $hoje){ echo "SIM! É hoje que vou subtrair o…
-
1
votes1
answer77
viewsA: Count in PHP via variable value
After clarification of doubts, I arrived at this answer: In your Controller you will count to get the total: public function index() { $cargos = \App\Cargo::latest()->get(); $setores =…
-
2
votes1
answer95
viewsA: Doubt about the onCreateOptionsMenu method
This is one of the public methods available from Activity that can be overridden. Its purpose is to simply create menu options of an Activity inflating an XML (Menu). It’s the menus that are usually…
-
6
votes1
answer74
viewsA: Problems with date transformation function
Let’s look at your code: $data = "12/13/2018"; $objetoData = DateTime::createFromFormat('d/m/Y', $data); In the variable $data you have 3 pieces of string 12, 13and 2018separated by slash. On the…
-
1
votes2
answers94
viewsA: How to sum this number? Example: "the number is 15 then it would be 1+5 = result"
Use the str_split to separate the digits and then add them up: $numero = 15; $num = str_split($numero, 1); echo $num[0] + $num[1];
phpanswered Andrei Coelho 6,196 -
6
votes4
answers6441
viewsA: Format Real value (br) to decimal (10.2) mysql
The number_format php requires the first parameter (the $_POST['valor'] in your case) be a float. string number_format ( float $number [, int $decimals ] ) So if your entrance is 20,05 this will not…
-
2
votes1
answer46
viewsA: How to make the result of a column?
You can add up inside the while <?php $valorTotal = 0; while($row_usuario = mysqli_fetch_assoc($resultado_usuario)){ $valorTotal += $row_usuario['total']; ?> Then you use the variable…
-
2
votes1
answer242
viewsA: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 6295552 bytes) in C: xampp htdocs Crawler temperature.php on line 11
The error happened when you tried to print the created object on the screen. This function print_r php uses output buffer and probably recursiveness, which further increases memory consumption. This…
phpanswered Andrei Coelho 6,196 -
3
votes1
answer129
viewsA: How to redirect a page using . htaccess?
With php you can put in your index as follows: $siteAtual = str_replace(["www.", "http://", "https://"], "", $_SERVER['HTTP_HOST']); if($siteAtual == "meusite.com" && $_SERVER['REQUEST_URI']…
-
1
votes1
answer700
viewsA: How to add Onclick in a Fragment?
The problem is that you are returning the View before setting up the Button and its System. On this line: return inflater.inflate(R.layout.fragment_more, container, false); The right thing is: View…
-
2
votes2
answers129
viewsA: SQL & PHP - Select everything using Where
You can automate this using $_GET or by mounting an array: Example: $filtro = ["ano" => "2018", "diretor"=> "Stalonne"]; $where = ""; foreach($filtro as $key => $value){ $where .= $key." =…
-
1
votes1
answer79
viewsA: Error generating XML from a Mysql database
This error means that you are calling a function from a variable that is not an object. This is because you are creating the element wrong here: $produtos = $xml->createElement=('Produtos'); The…
-
3
votes2
answers385
viewsQ: Problem with notification icon
I know there are several questions related to this. However, I have found nothing with my specific case. I will explain... I use the same code to display a notification both for notifications when…
-
-2
votes1
answer92
viewsQ: What is ( ) in php?
I’m making a comparison of two binary numbers by checking which index from right to left bits are different. I found a code as soon as it works: strspn(strrev("1111") ^ strrev("1101"), "\0"); This…
phpasked Andrei Coelho 6,196 -
0
votes1
answer74
viewsA: Checking if there is a result in the query
If you want to know if the query got any results greater than 0. You can use the mysqli_num_rows to count the number of lines. if(mysqli_num_rows($cronograma) > 0){ // faça algo }else{ echo "Não…
-
0
votes1
answer188
viewsA: Set timeout for specific function
My curiosity led me to this answer. I don’t know if it’s the best solution, but it works. To do what you want I got using execphp to run the file containing the function teste() in the background.…
phpanswered Andrei Coelho 6,196 -
2
votes1
answer105
viewsQ: Error creating variable inside IF
I was creating a script that always worked with me, however, I made a small change that almost blew my mind because I didn’t understand what happened and I didn’t find anything on the subject. Is…
-
0
votes2
answers385
viewsA: Change background image of a Recycler View Adapter after click
The way I did (I don’t know if it’s the best) was using LinearLayoutManager along with an internal interface in the Adapter: Adapter public class ListDatasAdapter extends…
-
1
votes2
answers385
viewsQ: Change background image of a Recycler View Adapter after click
The thing is, I created a Adapter amending a RecyclerView in an Activity I call through this function (within Activity): private void gerarDatasView(CalendarJur calendario){ LinearLayoutManager…
-
0
votes1
answer179
viewsA: Submit a form using request in php
In addition to the options suggested by Fernando... If you need give echo in all information typed in the form I would do so: echo implode(" ", array_slice($_REQUEST,0,count($_REQUEST) - 1)); The…
-
1
votes3
answers82
viewsA: Sequenced array within dropdown
In this case I prefer to use the for: <datalist class="" id="browsers" > <?php for($i = 0; $i < count($produto); $i++): ?> <option value="<?php echo $produto[$i]['cod_produto'];…
-
1
votes1
answer327
viewsA: Form via GET
You did not put it in the code but when you use the get method the values of your form elements will be entered in the url. So you probably have something like this: <form…
-
1
votes2
answers115
viewsA: How to read comments of a class, function or method?
You can also use token_get_all php native. filing cabinet index php. /** COMENTÁRIO */ function foo(){ echo "foo"; } Running... $array = token_get_all(file_get_contents("index.php")); foreach($array…
-
1
votes4
answers1283
viewsA: How to save form image directory in the database
The mistake is that you try to use the $arquivo["FOTOA"] as if it were the file name. It is not. This index, nor does it exist. You are probably getting an error of this type: Notice: Undefined…
-
1
votes1
answer731
viewsA: Read line by line from TXT and return at end (PHP)
If I understand correctly, you can use recursion to do this. This way it will always return the next line and return to the first one whenever file reaches the end. The limit is the for. function…
phpanswered Andrei Coelho 6,196 -
2
votes1
answer91
viewsA: Picking indexes with equal keys from a non-associative array
You can do it like this: EDITION The problem was that your array is inside another array. So I had to change the code for this: $newArray = []; $maxKeys = count(max($array[0])); // conta o número…
-
1
votes1
answer114
viewsA: INPUT VALUE with date Y-m-d format, but when showing on the screen show in d/m/Y format
Although I think I’d better convert the value... You can create 2 different inputs. One with the value that will be displayed and the other hidden with the value that will be used. // input…
-
1
votes1
answer53
viewsA: Array only loads last PHP record with PDO
You are always overriding the array value. That’s why you only fill the last line. The right is to add the values that are redeemed in the bank, thus: $arr = []; foreach ($dados as $consulta){ //…
-
3
votes2
answers465
viewsA: How do I verify registration in real time?
The problem is that you are trying to get the "email" id that does not exist. This line generates an error: var email = $("#email"); You need to enter the id in your <input/>: <input…
-
0
votes1
answer69
viewsA: Network application identification
With android (java), you can do this: public static String getLocalIpAddress() { try { // gera uma lista enumerada de todas as interfaces de endereços de rede for…
-
0
votes1
answer82
viewsA: php - create txt file and add all new records to it
You are always putting the file pointer at the beginning using the mode w. In this way, he will always write upon what has already been written. To write at the end of the file, you need to use the…
-
5
votes2
answers541
viewsA: Mount INSERT from SELECT
EDITION After talking to the Marconi, I realized that you need to know the data type of each field of your table. To do this, I used mysqli_fetch_field and with the values I saved in an array. The…
-
2
votes1
answer81
viewsA: Problem when trying to download large files
One option is to use x-sendfile . First of all you need to have mod_xsendfile in the server module. If you don’t have it, the above link has a download area. Then you need to configure it in your…
-
1
votes2
answers451
viewsA: PHP - Convert XML to Object
I created a static class called XMLobject to do this. It has 2 functions: gerarXML() : Receives an object and creates a file in the selected directory gerarObject() : Takes an xml file and generates…