Posts by Wictor Chaves • 8,445 points
320 posts
-
1
votes3
answers587
viewsQ: How can I sort a result in Laravel with a custom attribution from my model?
My real table is very large, so I will use this example I found on the internet to make it easier to explain my problem (source). Table fields: first_name last_name email password created_at…
-
0
votes1
answer431
viewsQ: How can I create a custom method in the Laravel model and match the result of another?
I am working with Laravel and created the following method to research a model: public function search($string) { return (strlen($string) > 0) ? $this->where('name', 'like', '%' . $string .…
-
2
votes2
answers178
viewsA: Add numbers inside input in sequence by clicking
It’s simple, just do it this way: $(".numeros_ligacao li a").click(function(){ digito = $(this).html(); var valor_anterior = $(".input_digitacao").val(); $(".input_digitacao").val(valor_anterior +…
-
5
votes1
answer52
viewsQ: How can I set a value in a specific variable in a function with optional attributes?
I made the following code to illustrate my problem: function teste($valor1 = '', $valor2 = ''){ echo "Valor1: " . $valor1; echo "</br>"; echo "Valor2: " . $valor2; } A very simple function, if…
phpasked Wictor Chaves 8,445 -
0
votes1
answer33
viewsQ: Import function with php 5.4
I am using an API, but it was designed to work in php 5.6+, but my server is with version 5.4, alias, my server is not the client server and this client server already has several applications…
phpasked Wictor Chaves 8,445 -
0
votes2
answers558
viewsA: Div captures the size of another
I created some div with some text: <div class="teste"> Lorem Ipsum é simplesmente uma simulação de texto da indústria tipográfica e de impressos, e vem sendo utilizado desde o século XVI,…
-
2
votes1
answer599
viewsQ: Keyword "use" in php
I was using an api when I came across the following code: $push->on('incoming', function (\InstagramAPI\Push\Notification $push) use ($ig, $socket) { ... }); I realized that the word "use" serves…
phpasked Wictor Chaves 8,445 -
1
votes1
answer1831
viewsA: Checking whether an item is visible or not on the page
You can check if it is on the screen by checking the scroll. As the buttons will disappear and appear, I will use the div to set when it should appear, you will do the same on your page by placing…
-
1
votes1
answer1860
viewsA: Hover on one element and changing the color of another element
Explaining why it’s not working The way you did: #segundo:hover #efeito{ background: blue; } It would only work if the div "effect" was inside the div "second". Solution with javascript You can do…
-
0
votes1
answer1645
viewsQ: The "npm run build" command is not working
My problem is the following when executing the command (To prepare the files for production): npm run build He doesn’t make any mistakes, apparently everything worked out:…
-
1
votes1
answer35
viewsA: Delete photo by clicking a link
It’s very simple to just add the following line: $("#excluir").click(function(){ $("#fileUpload").val(""); $("#imagem").css("display","none"); $("#excluir").css("display","none"); }); So it will…
jqueryanswered Wictor Chaves 8,445 -
0
votes4
answers7774
viewsA: Calling javascript function only once
Put a flag, I made a small example: <button onclick="myFunction()">Click me</button> <script> var clicado = false; function myFunction() { if(!clicado){ alert('ok'); clicado =…
-
12
votes1
answer4268
viewsQ: How to get any kind of cookie using Selenium?
Summary To summarize everything I said here below, I need to open Whatsapp Web read the QR Code and save cookies so that at the next Selenium startup I do not need to read the QR Code again. I found…
-
5
votes2
answers1104
viewsQ: Problem with group by
I have the following query: SELECT funcionario.*, emprego.data_admissao, emprego.data_saida, emprego.data_dispensa FROM funcionario,emprego,empresa WHERE empresa.id = emprego.id_empresa AND…
-
1
votes0
answers359
viewsQ: Selenium works with Firefox, but not with Chrome
I was normally using Firefox on Selenium with Python, but I wanted to do some testing using Google Chrome, so I made the following change: self.driver = webdriver.Firefox() To self.driver =…
-
3
votes1
answer100
viewsQ: Can a desktop program be considered client-side?
Always when I hear/read about server-side and client-side is related to web applications, but these terms can be applied to programs desktop? For example if I have an app that consumes a web-service…
-
3
votes2
answers1622
viewsA: Try/Catch Pdoexception does not work when error occurs
I found the problem, he was interpreting the Pdoexception as connected Pdoexception because of the namespace. namespace conexao; So I imported the Pdoexception. use PDOException; Source:…
-
3
votes2
answers1622
viewsQ: Try/Catch Pdoexception does not work when error occurs
I created the following method to execute my querys: public function setQuery($query) { try { $stmt = self::$conn->prepare($this->limpaQuery($query)); return $stmt->execute(); } catch…
-
1
votes1
answer75
viewsA: Ajax requests do not stop loading
Try to make the request in the background to not stop the other processes by putting async : true, I do not know why you are using setInterval, if it is possible to remove it: jQuery.ajax({ async :…
-
1
votes1
answer112
viewsA: How to update javascript file content on the page?
You can configure the browser through the meta tag not to cache the content of your site, this way: <meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control"…
-
1
votes2
answers80
viewsA: Use get_object_vars in a child class
What solved for me was to use traits, a very interesting feature that I didn’t know existed in php, but thanks for the Wellingthon force! http://php.net/manual/en/language.oop5.traits.php I created…
-
1
votes0
answers207
viewsQ: Communication between socket and socket stream
I made the following class: class Socket { private $socket; private $loop; private $enviarMensagem; function __construct(LoopInterface $loop, $enviarMensagem) { $this->loop = $loop;…
-
0
votes1
answer183
viewsA: Regex to validate mime type
You can do it this way, it gets simpler and easier to read: if (strpos($verifyimg['mime'], 'image/') === false) { die("Só imagens!"); } Using regex: if (!preg_match('/image\//',$verifyimg['mime']))…
-
8
votes1
answer22532
viewsA: How to open link in a new tab?
If you really want to use a div to create a link, follow the example using Javascript: <div class="opt" onCLick="window.open('https://www.google.com','_blank');">Txt</div> Replace…
htmlanswered Wictor Chaves 8,445 -
3
votes1
answer60
viewsA: Why in PHP and Mysql ! is it converted to 0 in some cases?
When you execute this command: var_dump((int) "!"); In fact it returns false since it could not do cast to int, if you do this way for example: var_dump((int) "qualquerCoisaString"); It will return…
-
1
votes1
answer180
viewsA: Runs php script in cmd with Curl
In the wamp folder there is more than one php.ini file, I had to change in all to work, this was the problem. Folders where php.ini files are found: C:\wamp64\bin\apache\apache2.4.23\bin…
-
2
votes1
answer139
viewsA: How to make minimized element or hidden on site?
You can use css and jquery, I’ll give an example here, in this example when clicking on the div it appears on the screen. First you "hide" it using css: .janela{ width: 100px; height: 100px;…
-
1
votes1
answer127
viewsA: Does not return the amount of records from the Postgresql database
Just do it this way: Select count(*) as contaRegistros from tb_produtos; It’s not working because of your Where: where prod_nome like '%"+ +"%'; You must have copied it from some chunk of code…
-
0
votes1
answer226
viewsA: problem with namespace and PDO
He’s interpreting the PDO as any class of his system, what you can do is: You can change: class Sql extends PDO{ To class Sql extends \PDO{ Or import using the use command at the top of the…
-
1
votes2
answers80
viewsQ: Use get_object_vars in a child class
I got the following class: class Dominio { private $teste; public function getAtributos() { return get_object_vars($this); } } And other classes that inherit it it(Dominio): class ClasseQualquer…
-
3
votes1
answer286
viewsA: Food Field Hidden via Jquery
Just like any other field: You can pick it up by the id: $(function(){ $('#id_campo').val(id_array); }); By name: $(function(){ $("[name='nome_campo']").val(id_array); }); Or by class: $(function(){…
jqueryanswered Wictor Chaves 8,445 -
3
votes1
answer86
viewsA: Do not pull information on index only
This way you take the current page, if it is different from 'index.php' it includes the code with the bar. <?php $array = explode("/", $_SERVER['PHP_SELF']); $pagina = end($array); if($pagina !=…
-
1
votes1
answer180
viewsQ: Runs php script in cmd with Curl
I am testing an api, while trying to use some features presented the following message: Something Went Wrong: Network: CURL error 60: SSL Certificate problem: Unable to get local Issuer Certificate…
-
1
votes2
answers293
viewsA: "if" does not match the condition
A practical example for better understanding: <?php $variavel = 'true'; if($variavel == "true"){ echo "1"; } if($variavel == true){ echo "2"; } if($variavel === true){ echo "3"; } if($variavel =…
-
1
votes3
answers135
viewsA: Why 1 2 is 3 and why when I display 0x33 appears 51 and 022 appears 18?
Example: <?php // 00001010 $a = 10; // 01101001 $b = 105; $c = $a ^ $b; # 01101001 # & 00001010 # = 01100011 // Exibe 99 Na tela // 01100011 echo $c; ?> So echo 1 2 is: 1 = 01 2 = 10 11 =…
phpanswered Wictor Chaves 8,445 -
2
votes2
answers142
viewsA: How to prevent a modal from appearing?
If the click event opens the modal is very simple to do is just do so: $('.btn').click(function () { if(condicao){ return false; } // Seu código para abrir o modal. }); So if the condition is true…
-
2
votes3
answers406
viewsA: PHP array that is not getting values
You were not assigning to the vector the value of the correct form: $vec = $temp; This way it would only return the first value: for ($i=1; $i<=20; $i++) { return $vec[$i]; } Upshot: <html>…
-
-1
votes3
answers1548
viewsA: Bulk mailing - Phpmailer
The script can be finishing the process before the time, try using the command: set_time_limit(0); Documentation: http://php.net/manual/en/function.set-time-limit.php It sets the time the script…
-
3
votes1
answer82
viewsA: How important is it really to validate codes by W3C?
Do you need it? whether you are a web developer or a web designer this tool will be a powerful ally. It is not only capable of compare a stylesheet with the CSS specifications, pointing out errors,…
-
4
votes1
answer447
viewsA: Remove space between menu and content
Change the page-Uilder in your css, put the padding 0 .page-builder{ padding: 0; } In the image you posted you can see that the top padding is with 80px
-
0
votes1
answer76
viewsQ: How can I fetch an html file from my server and embed it into a client page?
I developed a chat, to implement it is necessary to add on the page of the client a . js (So the client does not have the job of creating the markup on his site, just import the js and ready, like…
-
1
votes2
answers663
viewsQ: How can I differentiate a 'NULL' string from a null fact value?
I made this example for you to understand how the query is being made in the bank in my system. $sql = "SELECT * FROM tabela"; $result = $conn->query($sql); if ($result->num_rows > 0) {…
-
0
votes1
answer119
viewsA: Pagination in relation to Laravel
Model user: public function sites() { return $this->hasMany(Sites::class, 'user_id', 'id'); } Sites Model: public function user() { return $this->belongsTo(User::class,'user_id','id'); }…
-
4
votes1
answer941
viewsA: How can I divide the plots, adding only exact values for each plot, and a plot will be with an extra value?
I did it this way: double diferenca = compra.getValortotalentrada() - (totalP * compra.getQtdparcelas().doubleValue()); Let’s assume that the value is 100 then the totalLP would be 33.33 as in your…
-
2
votes1
answer52
viewsA: How to make all characters at the same time
I did it this way: .conteudo-banner .code-logo span:nth-child(2){ font-size: 6em; display: inline-block; position: relative; top:-4px; } font-size - Regulates font size display - Leaves span on the…
-
0
votes1
answer128
viewsA: Is it possible to install perlapi 5.14.2 in Debian 9?
First try the update (To update sources): sudo apt-get update And try to install again, if it doesn’t work try: sudo apt-get -f install So it will adjust the dependencies and try to install again,…
-
4
votes1
answer62
viewsA: Ajax, PHP Problems when receiving data
If you are able to use Alert, you are receiving a string, convert the json string to object: var dados = JSON.parse(response); You can change dataType too, this way: var hora =…
-
3
votes2
answers4145
viewsA: Script not authenticated
Problem This happens when the page is https and an http-only link is used in the script src. Example Page url: https:\\wwww.minhapagina.com.br Script used: <script…
-
0
votes1
answer33
viewsA: Syntax error Unexpected END_OF_LINE in line 2 php.init
Check if there is in the first line this: session.gc_maxlifetime[PHP] And if there’s this line much further down: session.gc_maxlifetime = 1440 If yes, try removing the first line in the case:…
phpanswered Wictor Chaves 8,445 -
2
votes3
answers408
viewsA: Sort array by itself within PHP Intel
I made a small example, I used the arsort function that already exists in php only to exemplify, but you can choose the one you want, this code will work if the sort also sorts the indexes.…