Posts by Bacco • 93,720 points
1,184 posts
-
4
votes2
answers363
viewsA: Problems with session_start() in Safari browser
As already stated in the comments, first of all it is necessary that your browser is accepting cookies. Once this is certified, consider that if you are going to use the session between the various…
-
4
votes2
answers544
viewsA: Rank database [#1 of 10]
I don’t understand if this is what you want, but if it’s just the numbering of the output lines, you can do something like this: SELECT @linha := @linha + 1 AS contador, tabela_desejada.* FROM…
-
4
votes6
answers261
viewsA: Parser Bbcode ignore what is inside [code]
Possible solution: <?php $code = ' teste[code]123[/code]bla teste[code]456[/code]bla teste[code]789[/code]bla teste[code]xyz[/code]bla '; While ( $pos = stripos( ' '.$code, '[code]') ) { $left =…
-
1
votes1
answer576
viewsA: How to block access to a hostname
First, you need to force all DNS requests (port 53 UDP and TCP) through your own resolve (for example, a DNS server that makes recursive queries), because nothing prevents the user from configuring…
-
19
votes4
answers12575
viewsA: What does "0x" mean at the beginning of hexadecimal numbers?
Has been answered by Lucas that "the prefix 0x identifies the number that follows as a hexadecimal constant", but I want to complement the answer with some relevant details: P: Why use a prefix? R:…
hexadecimalanswered Bacco 93,720 -
17
votes1
answer25431
viewsA: How to make a click shoot another click?
$("#button1").click(function(){ $("#button2").trigger('click'); }); Source: http://www.theextremewebdesigns.com/blog/jquery-trigger-click-trigger-method-binded-to-click-event-example/ Alternative…
-
7
votes3
answers596
viewsA: Conditions in Javascript
Expressions We usually call +, - * etc. mathematical operators, <, >, == of conditional operators, or by comparison, and and, or, or &&, || and similar of boolean operators 1. A set of…
-
16
votes4
answers844
viewsA: rtrim() to remove "<br>" also removes the letter "r" if it is the last letter in the string
This occurs with trim, ltrim also. The output is correct in 4 cases. The problem is the inappropriate use of the second parameter of rtrim: When you say rtrim( $string, "<hr>" ), is saying…
-
6
votes3
answers591
viewsA: SQL sorting only after the third character
If you want to sort by the letters of the example first, but keep the numerical order: SELECT * FROM cadastro ORDER BY SUBSTRING(nome, 3), nome Which pretty much equals SELECT * FROM cadastro ORDER…
-
4
votes4
answers425
viewsA: Query BD and show all results except the first
Simple and direct solution without subquery: $query = mysql_query( 'SELECT * FROM tbl_galeira ORDER BY id LIMIT 1,999999999' ). The second parameter of LIMIT is absurdly larger than its intended…
-
1
votes2
answers5945
viewsA: Get full monitor width using CSS3
Solution posted by OP in question: @-webkit-keyframes bounceOutRight { 0% { -webkit-transform: translateX(0); transform: translateX(0); } 100% { -webkit-transform: translateX(100%); transform:…
-
2
votes1
answer75
viewsA: UPDATE only fields that are more than 0 characters long
What you can do is to simplify the code a little by organizing the Ifs: <?php $sets = ''; $sets .= strlen( $janmembros ) > 0 ? "SET janvisitantes = '".$janmembros ."'"; $sets .= strlen(…
-
9
votes1
answer2102
viewsA: How not to enter repeated records?
Will always have some "crazy" proposing to give a SELECT to see if a certain record exists to enter later, do not waste time with these solutions because usually whoever does this has no idea what…
-
4
votes1
answer292
viewsA: How to re-create a URL with Accept-Language + split ?
Follows a quick fix 1: <?php $langs = array(); if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { // Cá entre nós, usar regex pra isso é forçar a amizade, mas lá vai :)…
-
5
votes3
answers18734
viewsA: Calculate Difference between Dates in SQL Server, with Years, Months and Days output
I adapted the solution of another answer mine: SELECT DataAdmissao, Hoje, YEAR( Tempo ) - 1 AS Anos, MONTH( Tempo ) - 1 AS Meses, DAY( Tempo ) - 1 AS FCCDias FROM ( SELECT DataAdmissao, CAST(…
-
8
votes3
answers25254
viewsA: Subtract date and display in YEARS, MONTHS and DAYS
The Problem: To calculate in years, days and months separately, you need to take some care, because some problems go unnoticed if you do not test with varied dates. Calculations based on days…
-
2
votes1
answer84
viewsA: Use different domains within a main website (city guide)
Here is a simplified path without depending on the .htaccess: PHP has the variable $_SERVER['SERVER_NAME'], which serves to indicate which domain the customer is using to access your website. For…
-
5
votes1
answer96
viewsA: Filter first result
Normal Path - Pure PHP: There are several ways, here is a well didactic: $query = mysql_query("SELECT * FROM teste2 ORDER BY id DESC") or die( mysql_error() ); // usei um contador para você poder…
-
4
votes4
answers3185
viewsA: 301 https protocol redirect to http
Based on the @Zuul response, follow the version for your specific case, RewriteEngine On RewriteCond %{HTTPS} on RewriteRule blog/tag/dengue-mata/ http://meudominio.com/blog/tag/dengue-mata/…
-
1
votes1
answer248
viewsA: Char problem * and fgets()
The problem is on this line: z[i].musica = fgets(a,255,arquivo); Here you are doing two things: Overwriting the a every line read Pointing all vectors to a This way, when iterating the vectors, you…
-
14
votes1
answer1137
viewsA: Find ID in a delimiter-separated ID column in Mysql
Only with SELECT As remembered by @bfavaretto, Mysql has a specific function for your need: SELECT * FROM chat WHERE FIND_IN_SET( '09', participantes ); the most general solution for various SQL…
-
11
votes2
answers6008
viewsA: How do I make the browser not store image caching with HTML or PHP?
Solution 1 - Serving images via PHP: This is a solution to serve images in a way that does not remain in the browser cache, setting the appropriate headers via PHP: <?php header( 'Expires: Sat,…
-
5
votes2
answers272
viewsA: How to create a box with two separate texts
As already answered by @carlosrafaelgn, there are several ways to do what you intend. I used the same technique proposed by him, and made only a few structural changes. Originally I was going by how…
-
2
votes2
answers67
viewsA: Consider null and empty strings as equivalent to each other
If you’re using it in more than one place, this is an implementation based on a reply from Sozão. static class Comparacao { public static bool SaoIguais(string a, string b) { if…
-
5
votes2
answers246
viewsA: Javascript reaching number 100
If you want a number that multiplied by 188 give 100 as a result, just do: fator = 100/188; // Perceba que usei 100/188 e não 188/100 cem = fator * 188; // Vai dar 100 (com algum possível problema…
javascriptanswered Bacco 93,720 -
4
votes1
answer268
viewsA: Save php Mysql data in a single table
The problem is that it seems to me that you want to join the data in one record only, but are creating two. After using each of your codes, you will have a table like this: Cartao | Data | Nome |…
-
3
votes1
answer2036
viewsA: How to manipulate CSS property in Angular JS
Using ng-class. I was "so ready" to reply in Sozão, that I enjoyed until Jsfiddle: Demo: http://jsfiddle.net/rd13/eTTZj/75/ JS app = angular.module('myApp', []); app.directive("click", function () {…
-
5
votes2
answers192
viewsA: Remove from account when value is 0
Since you used zero for undefined, just add 1 to the divisor for each non-zero (or 2 for noteSatisfaction, which has weight 2 in your example): SELECT ROUND ( ( ( notaAmbiente +…
-
4
votes4
answers6633
viewsA: How to make the browser "Back" button work on an AJAX site?
A direct solution is the HTML5 History API: history.pushState( estado, titulo, url ); To make more complete code and a better user experience, you can implement the popstate when changing the…
-
4
votes1
answer113
viewsA: Format Unix Time to display Data only
Instead of using the format U, which is precisely the Unix Timestamp, can use Y-m-d: $start = $start->format('Y-m-d'); See how Format the date in PHP.…
-
4
votes3
answers480
views -
12
votes2
answers3674
viewsA: How to create a 404 error screen
An error page is like any other page on your site, and can be created with the traditional tools you’re used to, using HTML, CSS, and even JS if you want. Keep in mind that by the nature of the…
-
4
votes1
answer904
viewsA: How to work with CSS media queries?
Separate the horizontal and verical measures of each element in their respective darlings horizontal and vertical: @media screen and (min-width:1280px) ... aqui voce põe larguras e posições…
-
4
votes1
answer213
viewsA: Repaint screen every little time without crashing - C++
One solution would be to use a Qtimer: QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(repaint())); timer->setInterval(200); // 200 milissegundos timer->start();…
-
3
votes4
answers2718
viewsA: Generate sequential Ids without losing the sequence
Simply create a parallel table of a row and a field just to save your increment. So, you update this table with contador = contador + 1 every time you need a new ID, and use it in the next…
-
7
votes1
answer347
viewsA: Direct sum by SQL query
Assuming the table has a field called contador and this is increased: UPDATE minhatabela SET contador = contador + 1 WHERE pagina = (id da pagina desejada) (Where is also there for example purposes.…
-
6
votes2
answers3776
viewsA: How do you make an element invisible when the value is 0?
Make the same system that changes the element number change the style. Follow example in PHP, adapt to the language of your system: // Antes: echo "<span…
-
4
votes2
answers155
viewsA: Convert Qvector<Qstring> to int in C++
You can convert a Qstring to int using Qt itself: vector.at( i ).toInt(); Or, if you only need the amount: QVector<QString> vector; vector << "1278" << "7" << "9"; int max =…
-
4
votes2
answers3113
viewsA: How to pick a random string from a list of strings?
Implementation of the Fisher-Yates shuffle algorithm: This solution implements the Fisher-Yates algorithm in the function Shuffle<T>(T[] array), which shuffles the order of items so that you…
-
12
votes4
answers2950
viewsA: Draw where the name cannot be drawn more than once
Implementation of the Fisher-Yates shuffle algorithm: A simple way out of your case would be to produce a scrambled copy of the list of names, so you can go on removing the same one by one. This can…
-
4
votes2
answers377
viewsA: Convert a decimal number to binary in LISP language
Assuming it is an exercise that needs to follow the reasoning of the statement, follow two examples taken of this page: (defun dtb (x &optional (callback #'princ)) (unless (= x 0) (dtb (floor x…
-
37
votes2
answers119390
viewsA: How to insert date and datetime into a table in Mysql?
You cannot directly enter data in any format you want in Mysql for fields datetime and timestamp. The format Mysql uses is the ISO standard: AAAA-MM-DD HH:MM:SS and some variants in the same order.…
-
4
votes2
answers474
viewsA: Mount query for database query according to checks marked
If the DB spelling is the same as the form: $checkboxes = Array( 'Básico', 'Avançado' ); $query = 'SELECT * FROM cursos'; $cola = ' WHERE '; // Deixar os espaços em branco "em volta". foreach…
-
4
votes2
answers13368
viewsA: Number of "bound variables" does not match the number of "tokens"
"Warning: Pdostatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid Parameter number: number of bound variables does not match number of tokens in /localhost/admin/crud/edit.php on…
-
9
votes2
answers1124
viewsA: How to organize by proximity using PHP?
Starting from Phpgeo itself, as mentioned in the question: Vincenty’s formula <?php use Location\Coordinate; use Location\Distance\Vincenty; $coordenada1 = new Coordinate( -23.575, -46.658 );…
-
3
votes1
answer576
viewsA: Error making dynamic PHP Insert
Try these settings in the following line: // Remoção do espaço nos primeiros ':' $Campos_valor= ':'. implode(', :', array_keys($sql)); And, to debug, change these: $query = "INSERT INTO $tabela (…
-
4
votes1
answer616
viewsA: Password security: Should I use Mysqli -> real_escape_string or bind_param?
The results are equivalent as much as: $safeuser = $mysqli -> real_escape_string($user ); $safepassword = $mysqli -> real_escape_string($password); $mysqli->query( "INSERT INTO usuarios (…
-
2
votes1
answer1293
viewsA: How to verify an encrypted password during Login?
IMPORTANT This answer was given to the situation raised in the question. Do not use crypt and salt fixed to store passwords, and in PHP use the function password_hash and password_verify for…
-
3
votes1
answer2343
viewsA: Receiving JSON with PHP via $http.post()
You cannot get the angular data via $_POST, because they are not serialized as parameters in the request body. To get the body of the request, read the data this way: $meuPost =…
-
7
votes2
answers2877
viewsA: How to apply password_hash for SELECT, INSERT and UPDATE?
First of all, I recommend reading this question: How to hash passwords securely? Here are two examples of password_hash using mysqli and bind_param, dispensing with the need to do any kind of escape…