Posts by Valdeir Psr • 10,804 points
433 posts
-
4
votes1
answer239
viewsA: PHP scandir filtered by name
You can do glob("{$dir}/{$nome}*");, so you can capture the file. Ex: ~/Images 01.jpg 02.jpg 03.jpg 04.jpg 05.jpg 05.png Php: <?php var_dump( glob("~/Images/01*") ); //Output array(1) { [0]=>…
phpanswered Valdeir Psr 10,804 -
0
votes1
answer35
viewsA: How to remove image upload requirement?
Just remove the condition $numFile <= 0. This way you will ignore this error and can register a post with or without image. if($numFile >=2){ echo '<div class="alert alert-danger">…
phpanswered Valdeir Psr 10,804 -
0
votes1
answer796
viewsA: Copy values from a PHP array
Use the function array_fill to create a array with predefined size and value. Ex: <?php $nomes = ["José", "Maria"]; $contagem = [1,2,3,4,5,6,7,8,9,10]; $a = []; foreach($nomes as $nome) {…
-
0
votes1
answer189
viewsA: Get Json response from URL
You’re probably not getting it because the site blocks some requests and asks to confirm that it’s not a robot. This protection works basically as follows: Upon entering the site, the code checks…
-
1
votes3
answers187
viewsA: Listing links from a page
In fact it brings all the elements. Only you are printing the element a within the attribute of another element a. Do it that way: const a = document.getElementsByTagName('a'); for (let b of a) {…
javascriptanswered Valdeir Psr 10,804 -
1
votes2
answers64
viewsA: CSS: How to insert an image element centered on paper?
How are you working with background, then you accurate define the width of header:before as 100%. To make the image not huge, just use the background-size with px instead of %. To position folder…
-
1
votes1
answer294
viewsA: Infinit Scroll - does not bring all BD data
Use the OFFSET or the LIMIT to capture from a given record. Ex: /* Dessa forma você irá capturar os 5 primeiros registros */ SELECT * FROM `users` LIMIT 5; /* Dessa forma você irá capturar os 5…
-
1
votes1
answer176
viewsA: How to create a folder in php and right after launch exec?
Use the function’s own return mkdir to check if the folder was created. Ex: <?php $folderClip = "clip"; $folderVideos = "~/Videos" /** * Tenta criar a pasta, caso a pasta seja criada * retorna…
-
0
votes1
answer1243
viewsA: Error:Execution failed for task - ':app:transformClassesWithDexForRelease
About the error Probably your app has more than 64K methods/references. Android app files contain files from bytecode executable in file format Dalvik Executable (or simply DEX). The specification…
androidanswered Valdeir Psr 10,804 -
2
votes1
answer379
viewsA: foreach in javascript for an error json return for a single registry
The foreach is a function of an element Array. Json can return a array. Ex: [{"nome": "Valdeir"},{"nome": "Psr"}]` but can also return a object. Ex: {"nome": "Valdeir"}` In your case, he’s returning…
-
1
votes1
answer180
viewsA: KEYCODE 9 JQUERY does not work
The keypress will run while the key has been pressed, the problem is that it works only for alphanumeric values, punctuation and etc. Does not work with Alt, Shift etc.. Use the keydown, it will…
javascriptanswered Valdeir Psr 10,804 -
2
votes3
answers219
viewsA: Add number in array and list it
To work with arrays you can start the variable as follows: totalSaque = new Array(); or totalSaque = []; To store the values is also very simple, you use the method push or inform the index you want…
-
1
votes2
answers455
viewsA: php count remaining hours
You can use the classes Datetime and Dateinterval. The class Datetime has a method (DateTime::diff) which, passing another date, it will calculate the difference and will return you a Dateinterval…
phpanswered Valdeir Psr 10,804 -
1
votes1
answer388
viewsA: Best practice for sending authorization via HTTP header
I tried something like this: Authorization: MinhaAuth Token="0PN5J17HBGZHT7JJ3X82", unidade="aaa". However I cannot recover this data separately in php. Answering the above question... Server…
-
1
votes1
answer68
viewsA: Hover slider Effect with Jquery does not work
The problem is on the line var $current = $area.find('img:visible');. When you do this, it will grab all the images that are visible, however, all the images are visible (how is one over the other…
-
1
votes2
answers146
viewsA: How do 'appear' effect on an element according to page scrolling?
Use the library scrollreveal together with the jQuery. Just use: sr.reveal('elemento', options); Below is an example. (Just scroll the page slowly) window.sr = ScrollReveal(); sr.reveal('button', {…
-
0
votes1
answer119
viewsA: Playlist with . load()
The function .load will only serve to download content and replace old content. Another point in your code is that you’re giving play before the contents of the list are downloaded. As the function…
-
1
votes1
answer331
viewsA: How to display sequential Divs using fade and controlling time?
You can use a asynchronous function to accomplish this. Just create a keyword function async in front. Ex: (async () => { /* Code here */ })(); This will allow you to use the operator await to…
-
2
votes2
answers794
viewsA: Access the emulator’s Sqlite database (and other storage types)
Yes. Just access the Android Studio menu: View > Tool Windows > Device File Explorer
-
1
votes1
answer1023
viewsA: Array to String Conversion Error
You can’t concatenate a array (array of exercises) with a string. When you need to turn array in string to save in the database, you can use one of the three methods below. Using json_encode You use…
-
1
votes2
answers572
viewsA: Check if item exists in array
You can also use the isset thus: public function atualizar($where, $dados) { print_r($dados); $operador = [ 'ope_nome' => $dados->nome, 'ope_cpf' => $dados->cpf, 'ope_login' =>…
phpanswered Valdeir Psr 10,804 -
0
votes1
answer117
viewsA: net :: ERR_INSECURE_RESPONSE
The SSL certificate of the site is invalid and so the browser is blocking. Use the URL only with http or use services from CDN. For example: https://cdnjs.com/libraries/peerjs…
-
1
votes3
answers110
viewsA: Insert Tags from Console
Your last code did not work because you are not inserting the element created on your page, besides not escaping the " (quotation marks) of attributes. You can also use insertAdjacentHTML to insert…
-
0
votes3
answers43
viewsA: Decrement of JAVASCRIPT forms
Use another column with a button and in the event onClick of that button, you add $(this).parents('tr').remove(); Ex: var counter = 1; jQuery('a.add-author').click(function(event){…
-
3
votes2
answers1017
viewsA: Multiple insert with php PDO and Mysql
The problem is that you are running the INSERT twice as often, because the first foreach will go through all the names (2 inputs = 2 insert) and then go through all the "types" (2 inputs = +2…
-
2
votes1
answer178
viewsA: Error picking up Radiogroup Android Id
The code is correct, however, you are capturing the value of the RadioGroup before the user marks an option and so the result is coming as -1. The correct is to capture the value within the event…
androidanswered Valdeir Psr 10,804 -
0
votes1
answer978
viewsA: photo of canvas buggy
The problem is that you are using canvas.toDataURL('image/png'); with an "empty" variable. You need to implement this code after document.body.appendChild(canvas) Thus: <!DOCTYPE hml>…
canvasanswered Valdeir Psr 10,804 -
1
votes1
answer1283
viewsA: mariadb connection error
The function mysqli_query serves for you to execute SQL command when it is already connected. For example: mysqli_query("SELECT * FROM users"); To connect to the database it is necessary to use the…
-
1
votes2
answers132
viewsA: Problem at the time of popular elements in the database
Error is in class constructor PDO. You are passing the value dbhost to indicate the database server, but the correct one is host. Thus: $db = new…
-
3
votes2
answers1343
viewsA: How to check the format and type of a text file?
Yes, it is possible. Just capture the values of the attribute input.files, it will return you an array of File and then just check. const inputUpload = document.querySelector("#upload");…
-
3
votes1
answer314
viewsA: How to extract information via regular expression?
Utilize -(.*?)_. - Starts the selection of the hyphen (.*?)_ Here is the sign of ? will limit until the first occurrence of _ Demonstration Demo with PHP Demonstration with Java Demo with Javascript…
regexanswered Valdeir Psr 10,804 -
2
votes1
answer48
viewsA: Add items to the array without creating a new level
Utilize array_merge to merge two or more arrays. $arrayAWSAgregado[] = array_merge(array( "product_alias" => 'teste', "months" => 1 ), $addonTypeSuccess);…
-
1
votes1
answer158
viewsA: Android Studio running problem
Add dependency with full version: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:26.1.0' } E in Gradle…
android-studioanswered Valdeir Psr 10,804 -
1
votes1
answer1899
viewsA: How to fill data in html input
To fill out a form with data that is on another page, it is necessary to use jQuery.ajax or XMLHttpRequest (JS Puro). First you need to replace the attribute type="submit" for type="button" and…
-
0
votes1
answer913
viewsA: Error: Catchable fatal error: Object of class stdClass could not be converted to string in
The problem is that fetch_field_direct returns an object and you cannot concatenate that object with a string, for example. To display the value you must use an attribute: Ex’s: $fields[$i]->name…
-
2
votes2
answers7834
viewsA: Jquery Focus in the field
You must apply the .focus in the input. It won’t work if you add in another element like span, div etc.. Thus: $("#region_tabVersao_N_txtM").focus().keydown(function() { $("#errortxtM").text("") });…
jqueryanswered Valdeir Psr 10,804 -
1
votes1
answer251
viewsA: How to organize project versions on Github?
I always use branches for that reason. To use it too, use the command: git checkout -b 5.3 and then git checkout master to return to the branch leading. I also always choose to leave everything in…
-
1
votes1
answer610
viewsA: Pass json parameters with php
When working with request submission, use the library Curl of php. Example: <?php $json = '{ "plan": "FFAC8AE62424AC5884C90F8DAAE2F21A", "reference": "MEU-CODIGO", "sender": { "name": "José…
-
1
votes1
answer302
viewsA: How to show interstitial ads after loading the home screen?
When you create a thread on Android, you nay can modify the thread user interface directly. It is necessary to use the method runOnUiThread. Thus: runOnUiThread(new Runnable() { @Override public…
-
5
votes1
answer1952
viewsA: Parse error: syntax error, Unexpected '?', expecting Identifier (T_STRING)
TL;DR The mistake nay is in the method translateExists as reported. The problem is that you are using a version of PHP lower than the version 7.1 About the error Since the version 7.0 of PHP, we can…
-
0
votes1
answer164
viewsA: JS works on Greasemonkey, but does not work directory on the page
The difference is that when you add Recaptcha through the code below, Google’s script automatically creates a iframe. <div class="g-recaptcha" data-sitekey="MY-KEY"></div> It turns out…
-
1
votes2
answers533
viewsA: How to delete PHPSESSID
The function session_destroy will not delete the PHPSESSID, will only remove all the contents of the variable $_SESSION. This function does not remove the session cookie. Just remembering that…
-
4
votes1
answer688
viewsA: java.lang.Nullpointerexception: Attempt to invoke virtual method 'void android.media.Mediaplayer.start()' on a null Object Reference
The error is not in declaring the variable mediaPlayer inside or outside the method onItemClick. The error is in the method releaseMediaPlayer. Note that this method is called after you instantiate…
-
1
votes2
answers603
viewsA: Get external links with PHP Curl
About the error This is because Google does not use the full file link in the attributes src, srcset etc. Instead, it uses only the path of the file: Ex: /path/to/image.png With this the browser…
-
0
votes1
answer147
viewsA: How to use the Location function in object orientation
The url is not equal as commented on in the question Note the lines below: Header: header("Location:/views/painel.php"); Html echo "<meta http-equiv='refresh' content='0;URL=views/painel.php'…
-
1
votes1
answer220
viewsA: Problems with 2 different versions of v7 library
The mistake These conflicts happen when a library uses the same dependency, but with different versions. In the gradle you can choose whether to use the full dependency or use only part of it. In…
-
1
votes1
answer387
viewsA: List mysql data in a modal using php
The attribute id must be used only in one element. Each new modal you have to use a id different. When you use several id equal, Javascript will capture the first element and disregard the rest. You…
-
4
votes2
answers1098
viewsA: How to add automatic scrolling to a div html?
Using Vanillajs To make this effect is quite simple, just use the method scroll window.. With this method you can change the coordinates X and Y. Ex: window.scroll(x-coord, y-coord); All right! No…
-
1
votes3
answers840
viewsA: How to obfuscate a PHP email by filling part of the characters before @ (arroba) with * (asterisk)?
You can also do through the function preg_replace. With the regex below you can group the first two characters and the two characters before the @. ^([\w_]{2})(.+)([\w_]{2}@) With the power of regex…
-
4
votes1
answer170
viewsA: Doubt about echo inside a loop
Just use the function ob_flush/flush to unload the buffer outgoing. <?php echo "aaaa, "; ob_flush(); flush(); sleep(5); //Espera 5 segundos echo "bbb!"; ob_flush(); flush(); sleep(5); echo "cc!";…