Posts by Bacco • 93,720 points
1,184 posts
-
3
votes1
answer96
viewsA: How do I choose which photo will appear on Facebook when sharing a page?
For integration with Facebook, you need tags meta opengraph. The image specifically is this: <meta property="og:image" content="https://dominio/imagem"/> In this case, you can even select a…
-
14
votes3
answers4722
viewsA: How to make a border lower than 1px?
First of all, important to consider these two situations: In standard configuration on conventional monitor (HD or smaller), 1px is a "little square" on the canvas, there is no way to paint half of…
-
4
votes1
answer1641
viewsA: Run console command and read the return in PHP
The shell_exec() already executes and returns the output of the command as string: <?php $output = shell_exec('df -h'); echo "<pre>$output</pre>"; ?> Remember that the user account…
-
7
votes1
answer594
viewsA: Return Json PHP to Ajax
The problem has nothing to do with AJAX or JSON, it is an error in the logic used. Your code is zeroing out the variable html inside the loop every time. Pass the html = "" out of the loop, so: var…
-
7
votes2
answers662
viewsA: Add content at cursor position with Ckeditor 4.5
The method for inserting arbitrary text at the cursor position is this: CKEDITOR.instances.editor1.insertText( 'texto' ); Beyond the insertText, note that there are the methods insertElement and…
-
7
votes2
answers1855
viewsA: Which is the best version Xampp / PHP , to update and what’s the difference?
There are two things to consider: Security It is essential to use at least PHP versions that have security fix, that even if they do not receive new updates, they have fixed vulnerabilities. To know…
-
13
votes3
answers249
viewsA: Change data value=" of tooltips if displayed in resolution less than 767px?
With a very simple function can solve this: function adjustTooltipOrientation(el) { var target = document.getElementById(el); var orientation = window.innerWidth<767 ? 'bottom' : 'right';…
-
2
votes1
answer986
viewsA: Button to add new fields in a form, with pure JS
Here’s a simple example of how to add divs with fields in an existing form: var line = 1; function addInput(divName) { var newdiv = document.createElement('div'); newdiv.innerHTML = '['+line +']';…
-
3
votes1
answer723
viewsA: how to update the database using checkbox
In the part which generates the form while($aux = mysqli_fetch_array($sql)){ $id = $aux['id']; $nome = $aux['nome']; $img = $aux['imgp']; echo <<<END <div class="col-lg-3 col-md-4…
-
6
votes3
answers2879
viewsA: How to know how many Sundays have php mysql months
Follows an alternative solution: function domingosNoMes( $mes, $ano ) { $t = gmmktime( 0, 0, 0, $mes, 1, $ano ); $ult = date( 't', $t ); $sem = date( 'w', $t ); return floor( ( $ult - 1 ) / 7 ) + (…
-
6
votes2
answers313
viewsA: Discovering the binary value in SQL Server
You can create a function for this: CREATE FUNCTION [dbo].[DecimalToBinary] ( @Input bigint ) RETURNS varchar(255) AS BEGIN DECLARE @Output varchar(255) = '' WHILE @Input > 0 BEGIN SET @Output =…
-
2
votes1
answer345
viewsA: SQL Like without considering the order of the parameters
Basically just sort out the conditions: SELECT * FROM TABELA_B WHERE ENDERECO LIKE '%RUA%' AND ENDERECO LIKE '%FULANO%' AND ENDERECO LIKE '%DE%' AND ENDERECO LIKE '%TAL%' AND ENDERECO LIKE '%67%'…
-
3
votes2
answers49
viewsA: Date passed as NULL to the database
On this line you’re trying to put $data_pagamento on DB: $stmt->execute(array(1, 2, 3, 4, 5, $preco, $data_pagamento)); If it is a date field, the string has to be in this format: 0000-00-00…
-
8
votes1
answer143
viewsA: Difference between PHP and PHP 64 Bits
Basically, because it was not taken care to abstract the numerical formats when they were elaborated, the PHP functions have different numerical capabilities in each version. Thus, in some…
-
8
votes1
answer1898
viewsA: How to return only records without matching in a JOIN?
First of all, for organization purposes we will keep the table of interest (product) on the left, and the reference (highlights) on the right, so we can use a LEFT JOIN. The LEFT JOIN is…
-
4
votes1
answer562
viewsA: Insert into two php mysql database
If it’s on the same server: $con = mysqli_connect( 'end.do.servidor', 'usuario', 'senha ' ); if( !$con ) die( 'Falha na conexao: '.mysqli_connect_error( $con ) ); $sql1 = 'INSERT INTO…
-
2
votes1
answer39
viewsA: Syntax error when executing database query
There’s a comma left after unit_catapult_tec_level, and this happens because of the poorly designed foreach (which adds comma after all elements unconditionally). A solution would be in place of…
-
8
votes4
answers11113
viewsA: What kind is appropriate for field that saves hours in mysql?
In the scenario described, it is semantically correct to store in numerical format. Note that you are not storing one timing in time, and yes a amount. If it were storing a temporal position, it…
-
3
votes5
answers4473
viewsA: In the ORDER BY of a SELECT change a comma for a period
As already answered, the only real solution is to correct the table field. Anyway, if it is to keep the "compatibility mode", if the decimals are fixed, this is enough to simplify the expression:…
-
2
votes1
answer1005
viewsA: How to make a horizontal line in relief?
It has many different ways. The hr not always reacts as expected, if you have no problems using another element, one simple way is this: .hr { border-top:1px solid #ccc; border-bottom:1px solid…
-
4
votes2
answers131
viewsA: How to insert a TAG with Comma or Semicolon
The line that detects the enter is this: if (event.which == '13') { The Code of enter is 13, you can put other conditions: if (event.which == 13 || event.which == 59 || event.which == 188 ) { But it…
-
3
votes1
answer193
viewsA: How do I show thumbnail files from my application in Windows explorer?
Windows Explorer is responsible for displaying icons and thumbnails, and has several features that can be added by third-party applications. What you seek are... Shell Extensions As Shell…
-
3
votes4
answers3012
viewsA: How to convert scientific notation to full number string
On the numerical accuracy: The question asks something that is not possible, convert 1.3388383658903E+18 for 1338838365890273563. The notation 1.3388383658903E+18 is only accurate for the houses…
-
3
votes3
answers303
viewsA: Convert date difference to string
A possibility, using simple subtraction and integers: $date1 = strtotime( '10/04/2016 15:03' ); $date2 = strtotime( '10/04/2016 16:28' ); $duracao = date( 'H:i:s', abs( $date2 - $date1 ) ); // Aqui…
-
4
votes2
answers3309
viewsA: Check if difference between dates is greater than X minutes in PHP
I always try to give an alternative with the primitive functions of date, because they are usually very simple and instead of objects return numbers, which are naturally efficient for subsequent…
-
3
votes1
answer362
viewsA: Rename posted fields into PHP variables
First of all, answering what was asked, a path would be to use "variables": foreach( $_POST as $nome_campo => $valor) { $$nome_campo = $valor; } But this is far from a good idea. Any misuse of…
-
6
votes5
answers2081
viewsA: Hide the last 4 numbers from a string
Follows solution with basic operations of string: substr( $ip, 0, strrpos( $ip, '.' ) ).'.***'; See working on IDEONE If you really want to change 4 digits: substr( $ip, 0, strrpos( $ip, '.' ) - 1…
-
4
votes2
answers235
viewsA: What does the _t suffix mean and when to use it?
To complement the @Maniero response: It’s a (human) convention to say it’s like. The C89 standard defines size_t, wchar_t, off_t, ptrdiff_t, among others. C99 defines things as uintptr_t, intmax_t,…
-
7
votes3
answers1083
viewsA: How can I create a filter to fill with zero left at the angle?
Alternative: filter('numberFixedLen', function () { return function (n, len) { var num = parseInt(n, 10); len = parseInt(len, 10); return (isNaN(num) || isNaN(len)) ? n : ( 1e10 + "" + num…
-
4
votes2
answers1148
viewsA: How to read what the user typed in a form?
A simple example of a dynamically generated form with PHP: pagina_um.php <form method="post" action="pagina_dois.php"> <?php for( $c = 1; $c <= 3; ++$c) { echo " Digite um numero:…
-
10
votes1
answer1031
viewsA: Sort Varchar field by taking into account groups and subgroups
The biggest problem was in the modeling decision, which prioritized the storage of the formatted value, and not the semantic value. Preferred solution: to remodel The ideal solution would be to…
-
2
votes1
answer261
viewsA: How to force my variable in php?
On the conversion to bool: There are several ways, the ideal is to cast at the time of use and not return. Some possibilities: $boolMenu = ( $menu == 2 ); // só é true quando for 2 $boolMenu =…
-
1
votes1
answer117
viewsA: Array in php with PDO
You probably need something like this: <?php ... $Pesquisar = $pdo->prepare( 'SELECT * FROM OrdemServico order by Status' ); $Pesquisar->execute(); $result = $Pesquisar->fetchAll();…
-
2
votes1
answer1667
viewsA: Apache ISO-8859-1 + UTF8. Is it possible to use both at the same time?
It is perfectly possible to work with several encodings on the same server. I’ve even been doing this with Apache and PHP for a long time, no problems. Note that to run two instances of Apache you…
-
6
votes2
answers5474
viewsA: Calculate day difference between two dates [PHP]
For the DD-MM-AA format specified in the question, we need to separate the date components to convert the year to 4 digits: $data1 = explode( '-', $_GET['data1'] ); $data2 = explode( '-',…
-
1
votes1
answer57
viewsA: "illegal start of Expression" when compiling on CMD
As @diegofm said, the syntax is: return count; Would be simpler return msg + 1; if you consider that you are matching the value of Count at the top line. You may have a logic problem the way the…
-
0
votes1
answer67
viewsA: Download tagged <a> in webview
As commented by Alisson, you need to put the attribute href on the tag: html.append("<a…
-
5
votes4
answers703
viewsA: Validate facebook profile URL
Something more or less like this: function fbUser( $url ) { preg_match('~^https?://(www.)?facebook.com/(profile\.php\?id=)?(.*)~',$url,$matches); return $matches[3]; } See working on IDEONE.…
-
2
votes2
answers79
viewsA: When giving the result of a query, this inserting only the first line
The basic problem with your code is that you are only giving an INSERT with a set of values. A solution precarious would give an Insert to each row returned from the first server: <?php…
-
5
votes1
answer110
viewsA: "Hotlinking is Forbidden" when using file_get_contents()
Usually the Hotlinks are detected by header Referer sent by browser. To specify a header in the use of file_get_contents, we have the stream_context_create: $opts = array( 'http'=>array(…
-
3
votes1
answer1006
viewsA: Variable with href
First of all, we have to fix the syntax errors. Arrays allow numeric or string indices. In your case you have not specified either one or the other. $lnbusca[celular] // celular não é uma string,…
-
3
votes1
answer853
viewsA: Viewing current month birthday in Fullcalendar
The first part of the problem is solved with the function MONTH of Mysql itself: SELECT * FROM clientes WHERE MONTH( start ) = MONTH( CURRENT_DATE ); MONTH() returns only the month of a date ( DAY…
-
4
votes2
answers240
viewsA: Search returns equal data
To reply from @gmsantos is very well elaborated and has already received my +1, I am only supplementing with a more basic version, for other readers with similar problem, which can be interesting…
-
2
votes1
answer1153
viewsA: How to remove br information from maps?
This is included in the documentation of Google Maps itself: https://developers.google.com/maps/documentation/javascript/styling See a very simple example, with examples of color change, and with…
-
4
votes1
answer1894
viewsA: Using Function within Select
View your code application: query( "SELECT VAL1, VAL2, ".funcao('VAL1', 'VAL2')." AS soma FROM Conta WHERE soma < 100" ); In this case, PHP will put these three things together, because you used…
-
10
votes2
answers12313
viewsA: How to convert binary to decimal?
In Sozão has this very simple code: #include<stdlib.h> #include<stdio.h> #include<math.h> int main() { int bin, dec = 0, i; printf("\nEnter A Binary Number: \t"); scanf("%d",…
-
3
votes3
answers303
viewsA: Border Radius does not work within a CSS class
An alternative would be to use inline-block instead of float (if the bar has full width is even better). See an example: .navbar{ padding:0; margin:0; border-radius:5px; background-color:#1A1A1A;…
-
4
votes1
answer1829
viewsA: Variable inside the WHERE of a select
Basically it’s syntax error, it doesn’t make sense: "Select * FROM tabele WHERE '$variável'" For when it does $variavel ="Item1 = 'Dado' AND Item2 = 'Dado'"; Your query is in quotes Select * FROM…
-
4
votes1
answer103
viewsA: Show widget and hide
Just use a .delay( milisegundos ) among the chained methods: $("#alerts").show("slow").delay(5000).hide("slow"); See working on Codepen. show("slow") shows the element; delay(5000) wait 5 seconds…
-
8
votes1
answer83
viewsA: PDO with Emulated prepares is unsafe? What’s the difference?
Understanding Prepared Statements First of all, let’s understand what the Prepared statements. When you send a query for the database engine, its SQL commands are transformed into a series of…