Posts by Bacco • 93,720 points
1,184 posts
-
2
votes1
answer417
viewsA: Remove bar values from graph
If to take the numbers off the top of the bar, change stackLabels: { enabled: true, style: { fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' } } for…
-
5
votes2
answers1714
viewsA: How to create a number generator from a Home number and a Final number?
JS solution return Math.random() * (max - min) + min; PHP solution rand( int $min , int $max ) See demo in JS: <button onclick="document.body.innerHTML += (Math.floor(Math.random() * ( 95000 -…
-
2
votes2
answers1283
viewsA: How to replace the text of an element with another text?
It’s the same logic as the code of colleague @Magichat, I’m just showing an alternative syntax and the use of innerText: document.getElementById("elemento").innerText += " texto"; <p…
-
7
votes1
answer757
viewsA: Transform string into array
In your case, use string is an unnecessary step as you can use JS objects even to get the desired result. Based on this, it follows a simplification of its original code: var variavel = [['Data',…
javascriptanswered Bacco 93,720 -
5
votes1
answer553
viewsA: Generate indented XML via PHP
XML Generated manually I did not understand the difficulty, since it is you who is generating the XML "manually". Basically, applying this logic across all lines would suffice: $xml_document .=…
-
5
votes2
answers419
viewsA: Doubt with php database connection with mysql
Basically both are personal choices. In practice, neither way is "better" or "worse" than the other, and they work the same way. If you have a connection only at the beginning of the code, do not…
-
6
votes2
answers1683
viewsA: How to sort this php array?
The solution is to use the function usort or uasort, who use a callback to use specific sorting rules: usort( $res, 'compara' ); uasort( $res, 'compara' ); In the above case, we are saying that who…
-
9
votes1
answer1742
viewsA: Is there a risk in using mysqli_insert_id?
There is no risk of "mixing" ID, by the following How it is returned from a column auto increment, he does not repeat. Since the function works with the current connection, and each access to a PHP…
-
6
votes3
answers605
viewsA: How to get a String size correctly using UTF8?
Function mb_ suffice, but need to configure for correct encoding: mb_internal_encoding('UTF-8'); Then the result is $string = "PAÇOCA"; echo mb_strlen($string); // 6 echo mb_substr($string, 0, 3);…
-
3
votes1
answer47
viewsA: Mysql giving error only when using query via variable
I asked a Hexdump to understand the reason your original Dump indicates 322 characters in a string of about 300. Precisely, in your Hexdump, I notice that it has several sequences of the character…
-
2
votes1
answer311
viewsA: WHERE clause with PHP-MYSQL array
If you are sure that in DB is always comma, just this: $sql = 'SELECT nome_carac FROM carac WHERE id_carac IN ('.$lista.')'; Applied to your code: <?php include 'conect.php'; $sql = 'SELECT…
-
2
votes1
answer558
viewsA: How to recover MYSQL password with mysqld error
First of all, the error presented is simply because you either do not have an executable with this name on the machine, or you are not running with the correct path. Once you have located the…
-
3
votes1
answer352
viewsA: Change iframe src and post date with javascript
Here’s a simple example of how to send a POST to a iframe: HTML <form id="formulario" action="http://httpbin.org/post" method="post" target="destino"> <input type="hidden" id="campo"…
-
2
votes1
answer749
viewsA: Handling multiple lines of code within a variable
First of all, you are mixing variable with playing dice on the screen, see the difference: if ($registros) { foreach ($registros as $registro) { $html = $html . '<tr>' . '<td>' .…
-
5
votes1
answer739
viewsA: How to convert Camelcase to snake_case in PHP (simply)?
Ready with a line has this one from Sozão $saida = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $entrada )), '_'); The question is, what happens if you do ___ at first? But it can be interesting…
-
11
votes3
answers10028
viewsA: How to display input type range value
@Renan has already posted a good solution (and already took my +1), I will leave here a similar alternative, with a few small differences in the syntax and methods used: <input type="range"…
-
6
votes4
answers934
viewsA: How can I decrease program processing time?
It follows an alternative as short as Thiago’s answer, but it works with numbers that are not multiples of 4: int main(){ unsigned short int in, i; scanf("%hd", &in); for( i = 1; i <= in; i++…
-
21
votes2
answers4131
viewsA: How can Whatsapp insert Emojis into the URL?
It doesn’t need anything complicated. Just have your route script redirect emoji to the right place, or even if you create a file or directory whose name is emoji itself. There is nothing different…
-
9
votes1
answer107
viewsA: Why do errors in PHP scripts run via the command line not appear in the apache error log?
One fact is that by the command line you will not be going through Apache, by itself it is expected that Apache will not log PHP errors. The directive of php.ini that controls the path of log of…
-
8
votes1
answer14054
viewsA: mysql Delete all records from a table except the first
Just for the record, this error appears when you try to modify a table and at the same time use it in a subquery. This serves to protect DB consistency. In your case, there’s no reason for the…
-
4
votes1
answer54
viewsA: ASP.net to send text with enter
I believe what you seek is this: protected void Page_Load(object sender, EventArgs e) { teste0989.InnerHtml="teste123<br>teste456<br>" } the InnerText already escapes the special…
-
3
votes2
answers1770
viewsA: INSERT PHP MYSQL does not insert
Basically it is inattention when seeing documentation or examples. You’re using a function that serves you no purpose here: or die( mysql_error() ); In fact, mysql_error() will always be empty in…
-
8
votes1
answer69
viewsA: PHP - Mysqli correct way
There’s no better, in the end it’s all the same. Looking at the PHP manual: http://php.net/manual/en/function.mysqli-connect.php You see that function mysqli_connect is synonymous with the method…
-
17
votes2
answers2598
viewsA: Can this asterisk pyramid code be further simplified?
An alternative: #include <stdio.h> int main() { int l, c; for (l=1; l<10; l++) { for(c=0; c<=7+l; c++) printf(c<9-l?" ":"*"); printf("\n"); } } See working on IDEONE.…
-
46
votes7
answers10590
viewsA: How do I know if today’s date is Saturday or Sunday (weekend) in PHP?
To find out if the current date is weekend: date( 'N' ) > 5 // hora local gmdate( 'N' ) > 5 // GMT Parameter 'N' returns the days of 1 to 7, being 1 Monday, and 7 Sunday, and works from PHP…
-
2
votes1
answer92
viewsA: Mysql query with RAND
With that query he takes 5 records, always prioritizing the is_new: SELECT campos FROM tabela ORDER BY is_new != 1, RAND() LIMIT 5 When the is_new is 1, the words is_new != 1 will return false,…
-
41
votes7
answers68940
viewsA: How to make SELECT with ORDER BY and different criteria?
The ORDER BY allows you to specify various criteria: SELECT ... ORDER BY expressao1, expressao2, expressao3... In your case, that’s enough: SELECT id, nome FROM categoria ORDER BY id != 100, nome…
-
11
votes2
answers1209
viewsA: How to manipulate bit by bit an integer in c or ccs?
General solution in C As a general rule, to "delete" a bit, that’s it: valor &= ~( 1 << bitPos); and to "light up," that’s it: valor |= 1 << bitPos; whereas bitPos is the bit…
-
7
votes1
answer803
viewsA: Take a specific part of a string
You can do it in a very simple way: $start = 'Email:'; $end = ','; $pos1 = strpos( $log, $start ); $pos2 = strpos( $log, $end, $pos1 ); $block = substr( $log, $pos1 + strlen( $start ), $pos2 - $pos1…
-
7
votes2
answers471
viewsA: How to get the difference between dates and turn into hours?
A good option in this case is to use TIMESTAMPDIFF, which already gives the result to the desired extent: SELECT TIMESTAMPDIFF( HOUR, created, NOW() ); You can use SECONDS, or other measures in…
-
1
votes1
answer69
viewsA: Conversation from hexa to int and toupper do not work
We had to add 10 in these lines, because the A is worth 10 and not 0: res += multiplier * (ch - 'a' + 10); and res += multiplier * (ch - 'A' + 10); So the function stays like this: int…
-
2
votes1
answer932
viewsA: Issue with importing CSV into Mysql
Lacked that: OPTIONALLY ENCLOSED BY '"' to escape the quotation marks. See the syntax in the manual: https://dev.mysql.com/doc/refman/5.7/en/load-data.html Thus remaining: $sql = " LOAD DATA LOCAL…
-
5
votes1
answer3294
views -
4
votes1
answer89
viewsA: When I click on button 2 is the time of button 1 that starts!
There are a thousand ways to solve what you want, the following is just an example. What we have done here is to use different Ids for all the elements involved, and we are passing the respective…
javascriptanswered Bacco 93,720 -
5
votes1
answer670
viewsA: Printing extended ASCII in C
The ASCII character table (American Standard Code for Information Interchange) goes to character 127 only. The extended ASCII term is misused, and even criticized(en), because it can refer to a lot…
-
3
votes1
answer154
viewsA: How to affect div who is before div with Hover
There’s no way in CSS to affect parent elements. For modern browsers, you can pass the Hover out of the input: .nav:hover { } and .nav:hover .img__logo { }: .nav {background:gray;padding:10px} .nav…
-
11
votes1
answer1433
viewsA: Doubt with Preparedstatement with INNER JOIN in Java
Taking this snippet of your code exactly as it is: String sql = "SELECT emp.cod_obra AS id_obra, ob.titulo, emp.dispo, emp.dataDevolu " + "FROM emprestimo emp " + "INNER JOIN obra ob " + "ON…
-
3
votes2
answers187
viewsA: Checks if in a value group there is a value x mysql
To test if a value is between several, the operator IN: SELECT * FROM tabela WHERE "Não" IN ( campo1, campo2, campo3 ) See working on IDEONE. Dice: (1, 'Sim', 'Sim', 'Sim'), (2, 'Não', 'Sim',…
-
4
votes3
answers1864
viewsA: Check if a date is earlier than another date
Colleague @lvcs already gave a good example of the use of Datetime, but I could not help saying that if the dates are strings in the format already used by Mysql, in the format AAAA-MM-DD, it is…
-
5
votes1
answer5102
viewsA: How to list the symlinks of a folder on Linux?
If it’s just for viewing, you can use the ls even: ls -l the option -l is the "long listing" that shows the details Links will appear with origin indication (->). http://linux.die.net/man/1/ls If…
-
7
votes2
answers9602
views -
3
votes1
answer137
viewsA: Inversion of Array
Reversing was, but you were reversing the impression too. Only changing the side of the variables already solves: void exercicio5() { float array[6] = { 10.1, 11.2, 12.3, 127.0, 512.17, -2.5 };…
-
6
votes2
answers2078
viewsA: Export data from an object to a csv file with PHP
PHP already has a function ready for this: http://php.net/manual/en/function.fputcsv.php An example, taking advantage of the code of colleague João: $pdo = new…
-
5
votes3
answers926
viewsA: PHP-Mysql Error Return: Call to Undefined Function
The first problem (which is what caused the error) is that you have invented a function. The function mysql_connect_db does not exist. Probably you confused with mysql_select_db. Basic problems like…
-
2
votes1
answer269
viewsA: Help with urlencode function
I don’t recommend you do this, for the urlencode is made to ensure interoperability between the browser and the application, and the correct decoding depends on the characters being properly encoded…
-
2
votes2
answers412
viewsA: How to send the result of a query by e-mail SHELL SCRIPT
The sendmail is a good alternative, but I usually use the mail same, in BASH, for already coming in a series of distros and be ready to use. Anyway, for basic sending, the syntax is similar, and…
-
1
votes1
answer499
viewsA: Print two foreach variables in a table in different columns - codeigniter
NOTE: I’m responding to what you put in "wanted" in the question. Looking at the rest of your code, it seems to me that you’re not having a safe way of getting the left column to relate to the right…
-
6
votes2
answers6419
viewsA: Run PHP script in Windows task scheduler
The most usual solution is to schedule this way: c:/caminhocorreto/php -c c:/caminho/para/o/php.ini [ -f ] c:/caminho/para/o/script.php This way, you’ll be getting the right executable and the…
-
4
votes1
answer125
viewsA: What happens on these lines in C++?
This is a reading routine similar to the "old mouse" "ball", and also used on machines that were common in "arcade", usually racing cars, where a round bulkhead with small cuts or holes was placed…
-
8
votes2
answers3936
views