Posts by David Alves • 2,470 points
112 posts
-
5
votes2
answers7757
viewsA: Is the for attribute of a label element good for something?
The tag <label> if associated with a form element allows you to "click" on that element by clicking on its label. This feature is especially useful if used in checboxes, botões and radio…
htmlanswered David Alves 2,470 -
1
votes1
answer1135
viewsA: Undefined error Property
The estate roles for $this does not really exist. At the beginning of your class, declare: private $role; That it will exist, thus avoiding the current error on line 61, but when you call…
-
2
votes1
answer47
viewsA: While com Href - PHP
Your error is missing quotation marks for the parameter href. The right thing would be: echo "<a href='caminho/".$row['caminho']."'></a>"; Leaving the content inside the parameter href…
phpanswered David Alves 2,470 -
0
votes2
answers766
viewsA: Compare php texts
I found the project https://github.com/chrisboulton/php-diff on Github that fits perfectly with my need. The example is very interesting. And the result is like this:…
-
1
votes2
answers766
viewsQ: Compare php texts
I need to develop/use a function to compare the text in two versions, to check what has been removed/added/maintained. One version I upload an html file and extract the plain text, and the other…
-
2
votes1
answer766
viewsA: How to delete all files and subfolders from a directory?
You can list all files within this directory and delete them that way: $arquivos = scandir(www.site.com/files/_deleted/); foreach ($arquivos as $arquivo){ // Verifica se é uma subpasta e apaga os…
-
11
votes4
answers12404
viewsA: How to compare if two javascript objects are equal?
There is no simple way to do this in Javascript, because internally the language has two types of approach to test equalities. Primitive data such as strings and numerals are compared by their…
javascriptanswered David Alves 2,470 -
3
votes1
answer106
viewsA: Level PHP Array
This recursive function will solve your problem: whereas $array_base is its incial array presented and $array_final is the desired exit. <?php $array_base = array( 0=>array('id'=>1,…
-
0
votes2
answers512
viewsA: Select/Where with parameter does not work on Oracle
The problem is in the identification of $id, is not passing the variable but string '$id' to be compared with a probably whole field. To solve your problem replace the query line with: $sql_query =…
-
3
votes1
answer37
viewsA: How to group results from a query?
Make the following logic with an auxiliary variable that will solve your problem: $query = (" SELECT r.receita, i.ingrediente FROM ptp_receitas r, ptp_receitas_ingredientes ri, ptp_ingredientes i…
-
3
votes2
answers140
viewsA: Validate a string with Regex
The Regex that will solve your problem is: (NWD+[0-9]*)( PADRAO \-) That means it will always seek to NWD followed by characters of 0 a 9 um número qualquer de vezes and finally seek to "espaço"…
-
0
votes2
answers3033
viewsA: Set current date in PHP and put HTML value in an input type='date'
Try it this way: <form action="add.php" method="POST" name="form1"> <div class="w3-section"> <label>Nome do funcionario</label> <input class="w3-input w3-border"…
-
0
votes1
answer22
viewsQ: Postgresql query bringing more results than expected
Hello, I have a situation in a system where I need to find out which student enrollments are related to a tutor in a class. The tables I have are: matricula containing foreign key with student…
-
0
votes2
answers3832
viewsA: How to use the PHP preg_match command
Hello, if your variable containing the phrase starts ALWAYS with "/", I say, for example, if the /command is not from the 4th character, it is possible to do this with the function strpos. An…
-
1
votes1
answer194
viewsA: What is the !=?
In c# != is a relational operator meaning "different from". Other relational operators are ==, <, >, <=, >=, meaning equal, less than, greater than, less than, less than or equal and…
c#answered David Alves 2,470 -
3
votes2
answers186
viewsA: Delete folder with CHMOD777 permission
To delete a folder, you first need to delete the files inside it. You can try this way: $dir='/var/www/casamentowagnerecamila.com.br/public_html/buscauiva/public_html/'.$row['nome'].''; // Se a…
phpanswered David Alves 2,470 -
1
votes1
answer1268
viewsA: Numeric keyboard input type="Text", Ionic Cordova
The type Tel brings the numeric keyboard to the mobile as the dial part. <input type="tel">
-
2
votes3
answers5235
viewsA: pass 2 parameters in button Onclick event
If it’s a fixed pass, it’s simple: <div class="modal-footer" style="margin-top: 165px" id="divBotao"> <button type="button" id="button" class="btn btn-secondary" data-dismiss="modal"…
-
2
votes1
answer134
viewsA: My POST is not sending anything
It has openings/closures of if wrong in your code. That way it’s right: <?php if (!empty($_POST)) { if (isset($_POST['login'])) { if (!empty($_POST['login'])) { $filtro = $_POST['login']; echo…
-
1
votes1
answer47
viewsA: library for input text with code sample
You can use the Tinymce. It is a textarea with editable freatures. You can leave only bold and italic, until the possibility of viewing the html code being generated from behind, among others. I’ve…
htmlanswered David Alves 2,470 -
1
votes2
answers309
viewsA: Include numbers to complete numeric sequence in PHP
One possibility to solve this is: <?php $array_do_banco = array('01', '03', '04', '06', '11'); $array_saida = array(); for($i=1; $i<13; $i++){ if(in_array($i, $array_do_banco)){ $matches =…
-
2
votes4
answers765
viewsA: Numeric sequence loop in PHP
One possibility to solve this is: <?php $array_do_banco = array('01', '03', '04', '06', '11'); $array_saida = array(); for($i=1; $i<13; $i++){ if(in_array($i, $array_do_banco)){ $matches =…
-
1
votes1
answer308
viewsA: How to catch an object inside another object in php?
In your example, you have an array containing 2 objects within your Direct object (0 and 1). To access the value of each of them is simple: $valor_do_0 = $data->custoIndireto[0]->valor;…
phpanswered David Alves 2,470 -
2
votes2
answers100
viewsA: Error missing commit in git
What happened was that you generated a commit with the "startup" message to your commit tree. This message only shows how many files have been modified, how many insertions, how many deletions and…
-
3
votes1
answer88
viewsA: Mount a two-dimensional array from another array
It is possible to do what you want in the following way: <?php // Seu array inicial $array = array("2018-03-28", "jantar", "lanche","2018-03-29", "lanche"); // Declaração do array final e…
-
0
votes3
answers471
viewsA: Delete last comma from a string
You can do this with the function str_replace $string = '"imagens":["upload/7057c705298193c513f07fbb8fbe2856.jpg", "upload/30c2dbcd5c890e763fab6ccfa63ab24c.jpg",…
phpanswered David Alves 2,470 -
3
votes5
answers73
viewsA: Calculate date difference and print these days
You can take a look at this class Dateperiod in php.net: $periodo = new DatePeriod( new DateTime('2018-02-08'), new DateInterval('P1D'), new DateTime('2018-03-10') ); It will return you an array of…
-
0
votes1
answer19
viewsA: Upgrading phpunit v5.1 to V6.5
I found that it is compatibility problem between my version of Zendframework(2.2.) and the new version of phpunit(6.5.). So I had to keep the old one.
-
0
votes1
answer19
viewsQ: Upgrading phpunit v5.1 to V6.5
Hello, I am upgrading phpunit from a 5.1 to 6.5 system, but from the upgrade, the tests that were all working successfully started to fail. The error message is: 1) Tests Administration Controller…
-
1
votes2
answers40
viewsA: Logout error, no connection class found
The problem there is that your require_once() cannot find the file Connect.php, probably because User.php is in a different folder than the other file you mention is working. For this you should put…
phpanswered David Alves 2,470 -
2
votes1
answer21
viewsA: Send more than one record to the same register in the Database
The ideal is to have a table for the worker and a separate table only for dependents. Then you use the id worker as foreign key in the dependent table. Already on the schedule. You allow the…
-
2
votes1
answer259
viewsA: Hours manipulation [HH:MM:SS] - php and mysql
Your calculation is correct, you just need to hit the display, which can be done as follows: $ps = "14:20:00"; $pe = "06:00:00"; $ts1 = strtotime( $ps); $ts2 = strtotime($pe); $diff = abs($ts1 -…
-
4
votes1
answer35
viewsA: Doubt about UPDATE (Edit.php)
It is possible if you create a field in your database called edicoes NOT NULL and default 0 and there you save the number of times that record was edited. When you edit the first time, it goes from…
-
0
votes1
answer69
viewsA: Mysql query based on checkbox result
Solving your problem is simple. In your query, use IN instead of =. Thus: $comprado = mysqli_query($conn, " SELECT pedidos.id as id_comprado, qtde FROM pedidos WHERE pedidos.id IN (".$check_id.")…
-
3
votes1
answer130
viewsA: Move array item to last position!
You can remove the item you want from the array and add it again (at the end) Example: $aux = $services[$key]; unset($services[$key]); $services[$key] = $aux;
-
0
votes1
answer594
viewsA: Linting is disabled for this query because it Exceeds the Maximum lengt
Apparently your Base64 encoding is crossing the character limit of the Mysql TEXT field. With a quick search, I identified that the maximum size of a TEXT field is 65,535 bytes, while the LONGTEXT…
-
1
votes2
answers170
viewsA: Append not working properly in a Select after AJAX request
The function load has documentation that can be seen here. It will load content within the parameter passed to it. An example with your case would be Javascript:…
jqueryanswered David Alves 2,470 -
3
votes2
answers3112
viewsA: Include in previous folder
The command to upload a folder is ../ so if you want to upload another folder use ../../header.php and so on. It is also possible to navigate between pages like: ../js/arquivo.js Remember that you…
phpanswered David Alves 2,470 -
0
votes1
answer737
viewsA: Ajax does not work on android
Add jQuery mobile to your project. It allows you to use jQuery commands for all mobile devices, both Ios and android. After entering the project, just use jQuery the way you’re used to it. Note:…
-
3
votes2
answers3064
viewsA: remove radio checked input
This will solve your problem: <div id="remover" onclick="$('input[name=gender]').prop('checked', false);"> Or: $( "#remover" ).click(function() { $('input[name=gender]').prop('checked',…
-
0
votes1
answer593
viewsA: CURL PHP request for a WEB Service
By mistake: Syntaxerror: Unexpected token - at parse (/app/node_modules/body-parser/lib/types/json.js:83:15) I assume the problem is using the command JSON.parse() which should be used to convert a…
-
2
votes1
answer55
viewsA: Keys in PHP Array
By your comments on the question, you said: when I try to access the name I get the return " Undefined index: name This is because the array in position [13] does not have the index name. To fix…
-
1
votes1
answer238
viewsA: Why populate a database?
Imagine that you are developing a simple system of registration and consultation, where there is the possibility to register a product, consult registered products and edit products already…
databaseanswered David Alves 2,470 -
1
votes2
answers750
viewsA: (bootstrap and php) How to create a row every 3 database records
You can do something like this: <?php $count = 0; ?> <?php foreach($seus_imoveis as $imovel): ?> <?php if($count == 0): ?> <div class="row"> <?php endif; ?> <div…
-
0
votes1
answer1824
viewsA: Time calculation for PHP + Mysql point
Oops, what you want is the result in hours from these strings. It can be done as follows: // Faz o cálculo das horas $total = (strtotime($item['dt_saida1']) - strtotime($item['dt_entrada1'])) +…
-
1
votes1
answer71
viewsA: disabling Jquery keyup button
According to the jquery documentation the class hasClass already returns true if the class exists in the last element. Then its line: if( $('#letter').hasClass('valid') &&…
-
0
votes1
answer16
viewsA: How to get aws service with aws-sfk-php-zf2 v 2.0. *?
I found a way that worked for me. Now the code is like this: use Aws\S3\S3Client; $this->s3 = S3Client::factory(array( 'credentials' => array( 'key' => $this->config['aws']['key'],…
-
0
votes2
answers104
viewsA: How to take checkbox values and insert them into the bank
On the line var checkbox = $('input:checkbox[name='check[]']:checked'); the correct would be: var checkbox = $('input:checkbox[name="check[]"]:checked');…
-
0
votes1
answer16
viewsQ: How to get aws service with aws-sfk-php-zf2 v 2.0. *?
I was using aws/aws-sdk-php-zf2 1.2. * and had to update to 2.0. * and now AWS SDK is v3. Before, I called the service with the code: $this->s3 = $serviceLocator->get('aws')->get('s3'); But…
-
1
votes0
answers538
viewsQ: Generating DOC from HTML content
I’m using the plugin Phpword to convert HTML text into a . docx file But when I go to download the generated file, I get only with very crazy characters like: PK#############!…