Posts by Rafael Withoeft • 2,287 points
57 posts
-
1
votes0
answers15
viewsQ: Conversion of Resource (stream) in php bringing unexpected results
Environments Local AS: Linux Mint 19.3; Bench: Postgresql 12.2 (Ubuntu 12.2-2.pgdg18.04+1); PHP: 7.3.17-1+ubuntu18.04.1+deb.sury.org+1. Amazon AS: Amazon Linux 2018 V1 - Beanstalk V2.9.3; Bank…
-
0
votes0
answers212
viewsQ: Turning rows into columns
I would like to turn some table values into columns. The structure of the table would be basically this: | id | idUnidade | mesCompetencia | valor | |----|-----------|----------------|-------| | 1 |…
mysqlasked Rafael Withoeft 2,287 -
0
votes0
answers179
viewsQ: Assigning values by jQuery is not working
I have a javascript code that fills fields in the form with "outsourced" data, most of the assignments are ok, the problem is in fields that we consider "Masked" and receive only numbers. The code…
-
1
votes0
answers41
viewsQ: Errors Accentuation Querypath
I’m using one of the recommended Ibraries in this answer, Querypath. To get the data I’m using Guzzle. However, I am having problems in the return of data (accentuation), it is replacing the…
-
0
votes3
answers5579
viewsA: Simple National Optional Consultation (by CNPJ)
I changed the code and now I use the Guzzle to make the requisitions and it worked. Follow the updated code of the class Consultacnpjsimplesnacional.php class ConsultaCnpjSimplesNacional { /** *…
-
8
votes3
answers5579
viewsQ: Simple National Optional Consultation (by CNPJ)
I’m trying to implement a query of Simples Nacional, the operation is similar to the consultation by CNPJ of the recipe. Details I’ve understood so far: After loading the page, runs a ajax (filing…
-
8
votes1
answer1017
viewsQ: Memory usage PHP images
I have an image upload and to treat the images I’ve used (Imageworkshop and Imagine), however the problem is not the libraries, it is the absurd amount of memory that is used in some situations.…
-
2
votes1
answer774
viewsA: Using the value of one datapicker in another
With some information passed by the author through the chat, we arrive at a code with the expected result by the same: Javascript: $(document).ready(function () { //Data atual var current = new…
-
1
votes3
answers30209
viewsA: SQL higher date of a record before the given date
Could you test this SQL? I was going to leave in the comments but it’s too big. Maybe you need some adaptation yet to get the exact result you need. Just let her know we’re modeling her. (I can’t…
-
34
votes5
answers31170
viewsA: What are Try/Catch Blocks for and when should they be used?
Block try/catch serves for handling exceptions, handling codes that may not be fully met and generate some exception/error. The try can recover errors that may occur in the code provided in your…
-
0
votes2
answers898
viewsA: Format tabs from an HTML menu
I edited your original code and the changes can be seen by comments from /* MODIFIED */; https://jsfiddle.net/hvgh1px9/7/ The main change was made in javascript, which in the case is the following…
-
8
votes3
answers1001
viewsA: Use OR operator in a PHP CASE
To use the same behavior in different "cases", you should write it this way: switch($options) { //Observe que não dei um break no case 1, pois ele executará a mesma função do case2. case 1: case 2:…
-
2
votes1
answer178
viewsA: Processing of returned values in the query
If you want to use "formatting" directly on SQL, you can try the following: SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(seu_campo, '.', 2), '.', -1) as dominio FROM sua_tabela Just replace the suggestive…
-
5
votes2
answers6374
viewsQ: String comparison
There are several ways of comparison, but I always see that the most suitable are (===, strcmp ou strcasecmp). Among these forms presented considered the safest (according to some websites on the…
-
1
votes2
answers189
viewsA: Search for results in related tables
Thiago, you can use the following SQL: SELECT cha.*, u.first_name FROM chamadosti as cha INNER JOIN users as u ON u.id = cha.created_by WHERE cha.status='open' ORDER BY cha.priority DESC It will…
-
3
votes1
answer3806
viewsA: Hikaricp - Unable to get driver for JDBC URL
Well, I changed the connection form of the Hikaripool class and it worked: Hikaripool package br.com.conexao; import com.zaxxer.hikari.HikariDataSource; import java.sql.Connection; import…
javaanswered Rafael Withoeft 2,287 -
3
votes2
answers768
viewsA: How to format Yii date?
You can use the following function: Yii::$app->getFormatter()->asDate($variavel_para_formatacao) Don’t forget to make the necessary settings in the file common/config/main.cfg 'components'…
-
1
votes1
answer3806
viewsQ: Hikaricp - Unable to get driver for JDBC URL
I’m trying to implement the Hikaricp to take care of the connections in a web project. Steps in a row: I created a Dynamic Web Project I added the .jars needed within WEB-INF/lib (HikariCP-2.3.5.jar…
javaasked Rafael Withoeft 2,287 -
3
votes1
answer87
viewsQ: Communication between JAVA reporting software and main PHP software
I thought a lot if I would open the question or not (it may be out of scope or broad or based on opinions), but as I am with many doubts regarding the use of a correct structure and that meets my…
-
3
votes1
answer529
viewsA: How to save data passed by parameter to the url in a Session?
You can use the following way: //Iniciamos a sessão session_start("customizacao"); //Armazenamos seus valores $_SESSION['imagem'] = isset($_GET['variavel_imagem']) ? filter_input(INPUT_GET,…
-
2
votes2
answers1206
viewsA: Click event not working
When you carry new items dinamicamente, the correct would be the use of the event ON jquery. In your case I’d be: $(document).ready(function(){ $(document).on('click', '.noticia', function(e) {…
-
4
votes1
answer2916
viewsA: Apostrophe causing error when entering data into Mysql
EDIT The most ideal solution would be the use of Prepared Statement, que chamarei de "PS"; Let’s take a look at the example: We keep your original string provided by the user and then use the PS…
-
0
votes2
answers1028
viewsA: Problem with while loop in PDO
You forgot to add the two points in the parameter array, in the case of the parameter activo (:activo) and to return more than one data, use fetchAll. Follow the final code: try { $result =…
-
2
votes2
answers841
viewsA: How to add a field of a given ID with multiple records?
You can use SUM() to sum up the votes and GROUP BY to join the records by your candidate’s code. SELECT SUM(TOT_VOTOS) FROM sua_tabela WHERE id_candadito = $seu_id GROUP BY id; You can recover…
-
1
votes4
answers2540
viewsA: Checkbox that selects all
Other users have already provided interesting solutions, but here is an alternative if you find interesting, I will put in javascript and jquery: Inversion of Selections JQUERY…
javascriptanswered Rafael Withoeft 2,287 -
1
votes6
answers1754
viewsA: Hide dives after selecting another category
I don’t know how your select is, but I believe this would work for you: EDIT: Applying your reality now, I believe it fits you: $("#1").hide(); $("#2").hide(); $("#3").hide(); var lastOpen = '';…
-
3
votes3
answers242
viewsA: Show list of 6 in 6 items
For a pagination created dynamically and without numbering (next and previous button only) you can use Jquery Easy Paginate. Follow a small example (You can change the css as you wish too, or even…
jqueryanswered Rafael Withoeft 2,287 -
3
votes1
answer48
viewsA: Click on only one element
If you allow me to change your code a little I think the following would fit you: I changed your javascript to the following: $(document).on('click', ".produtosMenu li span", function() { var index…
jqueryanswered Rafael Withoeft 2,287 -
3
votes2
answers15045
viewsA: count how many days a date range has in another date range
You can count the days difference between two dates in Mysql using the function DATEDIFF. SELECT DATEDIFF(CURDATE(), '2015-01-01'); //Retorna 56 (Base: 26/02/2015); For your case: SELECT…
-
2
votes1
answer254
viewsA: See third party pages
You can submit a request for POST using cURL; First Step Let’s check if he’s installed in his php.ini check that line: ;extension=php_curl.dll If commented, take the ;. Basic Use // Inicializamos o…
phpanswered Rafael Withoeft 2,287 -
6
votes3
answers1255
viewsA: Display text at random
Marcelo and Diego have already provided efficient solutions to their problem; But here I will put a slightly different one, in case you are interested at some point in showing random texts ...…
-
2
votes1
answer107
viewsA: Problem with push button by ajax id
I tried to improve your source code a little by simplifying some syntax for example <?php echo ?> for <?= ?> (PHP 5.4+), I changed the way you were using the click events, so getting…
-
1
votes2
answers10740
viewsA: simple array arrays for json_encode
I believe that’s what you need, just adapt a little: $array = [ 0 => ['id' => 1, 'nome' => 'teste', 'email' => 'email'], 1 => ['id' => 2, 'nome' => 'teste2', 'email' =>…
-
0
votes2
answers94
viewsA: Jquery for Followers Index
I’ve made a very simple example for you and it needs a clear complement to your need, but the basics I believe are there: Script <script> $(document.body).on('click', '#follow', function(e) {…
-
16
votes3
answers94464
viewsA: How to mask an HTML5 input?
You can mask a field using: Jquery Mask Plugin Documentation Example of use: $(document).ready(function(){ $('#telefone').mask('(00) 0000-0000'); }); Or in html itself: <input type="text"…
-
1
votes3
answers11171
viewsA: Add jquery "loading" effect
One of the solutions is using the Sonic.js; Documentation and examples: https://github.com/padolsey/sonic.js/blob/master/README.md How to use? You can create a javascript function this way and add…
-
2
votes1
answer126
viewsA: List ID with name in the same table
Analyzing what the user provided information (parent and daughter categories are in the same table) the solution to the case would be more or less the following: SELECT * FROM categorias as cat1…
-
4
votes2
answers1245
viewsA: How to take a variable value by file_get_contents
You are just ordering the page news php., not sending any email parameter; Try it this way: $mail->IsHTML(true); // Define que o e-mail será enviado como HTML $mail->Subject = "Assunto";…
phpanswered Rafael Withoeft 2,287 -
1
votes1
answer90
viewsA: Delete data by checkbox
Taking into account the options the user proposed I made the modifications where they were needed: if (!isset($_POST['categoria'])){ $categorias = '' . implode('\',\'', $_POST['categoria']); $id =…
-
4
votes1
answer2601
viewsA: How to take data from a Select Mysqli and send newsletter
Test as follows: I put the second while code in the first so eliminating it (because there was no need for it) and simplifying its code as well. What happened before: the first while only kept an id…
phpanswered Rafael Withoeft 2,287 -
1
votes1
answer197
viewsA: I need to retrieve the information from a page. How can I continue what I started?
Here is an example using phpQuery-one-file for ZIP query; the Curl part is not included as the focus is on using phpQuery; this is one of several possible solutions. phpQuery:…
-
1
votes1
answer55
viewsA: Problem when selecting php checkbox
You can use as follows (I have done according to the code you provided, only made the necessary changes, test and let us know the result): <input type="checkbox" name="categoria[]" <?=…
-
1
votes1
answer213
viewsA: How do I add an input type="radio" in a form?
Something like this, huh? However this would be in html, you would like to create a PHP function that would mount these fields (Sorry I didn’t quite understand your proposal)? <form action="#"…
-
3
votes3
answers656
viewsA: What is the best way to convert HTML entities with Javascript?
I use two functions I found on the internet, take a test: //https://stackoverflow.com/questions/1219860/html-encoding-in-javascript-jquery function htmlEncode(value) { //create a in-memory div, set…
-
0
votes1
answer1933
viewsA: I would like to change an attribute of a dynamic element with jQuery
I tested it here and it seems to be working... $(document.body).on('click', '#tab-departamentos a', function () { $('textarea').each(function () { var a = (this.scrollHeight - 12) / 20; alert(a);…
-
2
votes2
answers5553
viewsA: Clear inputs inside form after sending the message
You can also use: $('#form_id_teste input[type="text"]').each(function() { $(this).val(''); }) or: $('#form_id').trigger("reset"); Sources or references of the same question:…
jqueryanswered Rafael Withoeft 2,287 -
1
votes1
answer85
viewsA: Problems with PHP 5.2
Try modifying your code for something like: $querySQL = 'SELECT * FROM tabela_usuario WHERE id = 1234'; $query = mysql_query($querySQL); if (!($row = mysql_fetch_array($query, MYSQL_ASSOC))) { echo…
phpanswered Rafael Withoeft 2,287 -
4
votes2
answers1627
viewsA: Fetch data from last 7 days from current date (2014-12-11 11:06:09)
I tested it here and it worked: SELECT * FROM sua_tabela WHERE seu_campo BETWEEN TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 day)) AND NOW(); I believe there’s an easier way to do it.…
-
1
votes3
answers14756
viewsA: Centralize one div within another 100% div
I made some modifications to your code using images from the internet to simulate and I believe that’s what you would need... if not, please let us know! I added margin: 0 auto; in your class…
cssanswered Rafael Withoeft 2,287 -
5
votes1
answer190
viewsA: How to show certain data depending on who logged in
I edited your SQL a little according to the information passed by the comment and was like this: (Don’t forget to change the SQL to your case, the fields I placed fictitiously wondering how would be…