Posts by Bacco • 93,720 points
1,184 posts
-
3
votes1
answer373
viewsA: Error running mysql_query
Basically it’s a typo. The PHP manual is clear in the order of the parameters: mysql_query (string $query[, resource $link_identifier] ) More details:…
-
2
votes1
answer127
viewsA: Errors when compiling program using Mysql resources
That’s typo on this line: ~$ gcc teste.c -o teste $(mysql_config -libs) IS --libs and not -libs See the difference typing right: [user@server ~]$ mysql_config --libs -rdynamic -L/usr/lib/mysql…
-
10
votes1
answer1523
viewsA: Effect of skirting a div’s edge, as if drawing "by hand"
Using transitions with delay, you can do. See an example: a { display:block; position:relative; background:#ffc; width:300px; height:180px } a::before, a::after { content:""; display:block;…
-
4
votes1
answer981
viewsA: Get complete XML content without removing tags
The content is returning perfect with the tags, it is normal not to be able to see them on the screen, because the browser tries to interpret as HTML. Just a small correction, if you want to see the…
-
6
votes3
answers9114
viewsA: What are the differences between printf, fprintf, sprintf, snprintf, printf_s and fprintf_s?
All are defined in <stdio.h>: int printf( const char *format, ... ); <C99 int printf( const char *restrict format, ... ); C99+ printf writes in the stream outgoing stdout. int fprintf( FILE…
-
3
votes1
answer259
viewsA: Error md5 when renaming upload php file array
Like already commented by William, failed to say what it is that you are generating the md5(). As anyway, in your case the md5 is of little use, one possible solution is this: $file_name =…
-
2
votes1
answer124
viewsA: Doubt - Google Drive + Sqlite
Short answer: Not. Shorter answer: Hypothetically, you could install a driver mount google drive as a real device, with a filesystem similar to the OS in use, which would make file access…
-
12
votes1
answer120
viewsA: Loop duplicating entire table
You have to remove the table and header from the loop: <?php ... $dbc = mysqli_connect('senha_adm'); $query = "select carro, barco, aviao, moto, triciclo, velotrou, dataCadastro from agencia";…
-
3
votes1
answer456
viewsA: Read the name or type of a remote file opened with "fopen"
Simplest solution, the $http_response_header: The variable $http_response_header is of great help in the URL of your question. When you use fopen() in remote resources, it is automatically populated…
-
12
votes3
answers148
views -
6
votes2
answers645
viewsA: Create PHP automatic file
A solution would be to create a template folder, with everything you need, and copy to the new user folder. See a code ready, taken from the Stack Overflow in English <?php function…
-
3
votes1
answer539
viewsA: Mount an image from other images with PHP
Your question is a little broad, but it follows a basic code: Suppose the letters are 60 60px in size and saved as A.png, B.png etc.. $string = 'ABELHA'; $len = count( $string ); $im =…
-
8
votes2
answers7430
viewsA: Calculate time interval in hours and minutes considering different days
For periods of 24 hours or more, date should be used: It is necessary to specify the date in these cases, for disambiguation. PHP already has very efficient date functions to use in mathematical…
-
3
votes2
answers100
viewsA: I can’t break line using Javascript
I don’t see much point in wanting to use line break in input. In this case, the appropriate would be a textarea. Just use \n to break the lines, see working: var nick = 'XYZ'; var descobriu = 'por…
-
1
votes2
answers308
viewsA: String concatenation in a directory
PHP already has appropriate constants to return OS bars, and other things related to filesystem. To return the bars, the constant used is: DIRECTORY_SEPARATOR Example of use: $path =…
-
7
votes5
answers426
viewsA: Explodes with name indexes (associative)
It is the same logic of @Miguel, (who already received my +1), I only posted to propose a rearrangement in the structure, in case will vary the amount of data depending on the occasion: $user =…
-
4
votes1
answer176
viewsA: Dynamically limit inputs
Just use the same logic you used when removing the field: ... if($("tr.linhas").length > 1){ ... This test serves to remove only if the number of lines is greater than one. See how it is copying…
-
41
votes2
answers1936
viewsA: What do "n" means, numbers and signals on the "Nth-Child" or "Nth-last-Child" selectors?
"Nth" can be "translated" as "nth". "nth" precisely because it is "n", ie any number. When you say 3n, it means "every three", "5n" every five, and so on. The + and - then indicate an optional…
-
5
votes2
answers892
viewsA: How to fix CMD accentuation error?
First of all: the problem seems to me in its code, and not in the CMD. If you are going to make applications for the console, the most practical way is to change the encoding in your IDE/text editor…
-
2
votes1
answer410
viewsA: Get totals by date range, relating to additional table
You have a lot of problems in one question. Grouping and summing One of them is the problem of grouping and totalization. You have several releases for id_tipos different but wants to show one per…
-
3
votes2
answers443
viewsA: The "pay()" function does not return the correct result
Follow a "short" version only to complement the post. I did it based on reply from @inkeliz (which, by the way, is much more didactic for those who are learning, and has already taken my +1):…
-
4
votes1
answer1132
viewsA: Problems with PHP connection -> Mysql
The first mistake, HY000/1130 is what matters in the case: Warning: mysqli_connect() [Function.mysqli-connect]: (HY000/1130): Host '10.1.1.25' is not allowed to connect to this Mysql server in…
-
5
votes2
answers59
viewsA: Merge variables and include 0 to an 11 digit php field
sprintf() The sprintf is a very practical alternative to format your string: $barra = sprintf( "%'02d%'02d%'07d", $v_ficha_loja, $v_ficha_loja, $v_sequencia ); See working on IDEONE. % to indicate…
-
19
votes2
answers6108
viewsA: Random draw, but with different odds
As explained by @ramaral, you divide the percentage into proportional ranges. The first 30% is obviously a blue ball. To know if it is a red, the logic is to be greater than 30, and less than or…
-
12
votes4
answers1052
viewsA: How do we know the date is the last day of the month?
To get the last day of the month just that: date("t", $data) == date("d", $data ) Can use gmdate if you prefer. Usually, to be used in loops, use numbers, as obtained by time() is much more…
-
4
votes2
answers629
viewsA: Response write inside Response write
If in HTML body: <h1><%= date() %></h1> If you’re gonna concatenate strings: Response.Write "<h1>" & date() & "</h1>" If your source code is stored with…
-
5
votes3
answers68
viewsA: regex Return false?
In theory, enough ^max\d{1,3} The dot in your original Regex takes other characters, like max_121. Max120 would work for the wrong reason, the point would take the 1, and the /d{1,3} would take the…
-
7
votes1
answer59
viewsA: How to synchronize two scrollbars based on percentage?
It was just a mathematical adjustment: Of var p = (sf / 100) * from.scrollTop; to.scrollTop = (st / 100) * p; To var p = from.scrollTop / sf; to.scrollTop = st * p; function syncScroll(from, to) {…
-
4
votes2
answers80
viewsA: Is it possible to use Heredoc with special characters in an array?
In principle, HEREDOC ends only when it finds the defined character sequence, at the beginning of the line and at most with ; at the end when necessary. Correction of your case: $name_code = array (…
-
10
votes2
answers534
viewsA: CSS tab system stops working when changing quantity
The architecture of this CSS is not the best at the time of maintenance, because it depends on the amount of intermediate elements for each tab. If generating dynamically, with a server-side…
-
2
votes2
answers63
viewsA: Operator Bitwise Right
See the 4 in base 2: 00000100 Now let’s move it once to the right ( 4 >> 1 ): 00000010 If we moved twice ( 4 >> 2 ): 00000001 Moving 6 houses, the bit was "gone", so the result 0. Look…
-
4
votes2
answers1283
viewsA: How to exchange values of two variables without using a third one in php
Basically this: list( $a, $b ) = array( $b, $a ); In the newer versions: list( $a, $b ) = [ $b, $a ]; It is important to note that both the above solutions and the use of a third variable are…
-
4
votes2
answers994
viewsA: How to also treat accented strings and without accents in a LIKE
You need to use the correct collation in your database. For example, if the column of your table that will be searched is in UTF-8, you need to use the collation utf8_unicode_ci ("ci" at the end of…
-
3
votes1
answer997
viewsA: Parse error: syntax error, Unexpected ''",>'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'
Separate numeric expressions with ( ), otherwise concatenation happens before the mathematical operation. Correction: echo '<div class="letras"> <label class="alternativa" for="'.($i+1).'"…
-
53
votes1
answer3274
views -
16
votes1
answer5857
viewsA: What is the difference between /bin/bash and /usr/bin/env bash?
First of all, the #! in a shell script is known as shebang or hashbang. It has the shape of a comment (lines started with # are usually ignored by the shell), but the ! then serves to indicate which…
-
3
votes1
answer1455
viewsA: HTTP and HTTPS redirection with exception
Probably that solves it. It’s similar to its first version, but it has been fixed a != and the https in the RewriteRule RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/api.*…
-
4
votes1
answer1977
viewsA: How to put Scroll in table inside div with width 100%?
First of all, a warning: I didn’t solve just by touching the point you asked, I re-structured the HTML as a solution to the problem as a whole. Basically, I removed the table from outside, after…
-
1
votes1
answer116
viewsA: input in PHP with fields filled
Enough for a echo in PHP returning the value in the field value: If it’s in the HTML part Nome: <input name="nome" value="<?php echo htmlentities( $nome ); ?>"> or in the PHP part: echo…
-
9
votes2
answers6054
viewsA: Windows CMD - Setar String with Accentuation
The likely problem is that when saving the file, the correct encoding was not chosen. The first step is to know the encoding correct, typing the command chcp on the console: In most systems, the…
-
9
votes1
answer14408
viewsA: Block direct access to files and directories
The option you seek is this: Options -Indexes Can you direct us .htaccess (if this override is enabled in Apache). Example of configuration with Directory, instead of .htaccess: <Directory…
-
12
votes4
answers1229
viewsA: How do you know if a certain day is a weekend?
To create a date, you have the functions mktime and gmmktime: mktime ( [ int $hora [, int $minuto [, int $segundo[ , int $mes [, int $dia [, int $ano [, int $is_dst ]]]]]]] ) Knowing this, just use…
-
11
votes2
answers5258
viewsA: How to redirect http to https
This is a very simple alternative: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] RewriteRule ^.*$ https://www.domain.com%{REQUEST_URI} [R,L] If you’d…
-
1
votes2
answers224
viewsA: MYSQL NOT IN array php
Basically you need simple comma quotes: $comma_separated = implode("','", $csv[$i]); You also need to see if the $csv[$i] is really what you want. A demo code. Use echo to avoid DB testing: $lista =…
-
8
votes2
answers1107
viewsA: foreach can replace fetch_array?
You can do it all at once with foreach, the question is whether it’s really worth it. To use the foreach you would need to get the data, either with mysqli_fetch_all or accumulating somewhere with…
-
2
votes2
answers109
viewsA: How to ensure that a SESSION expires if the user accesses a copy of the application that is in another directory
Instead of changing the logic of the system, a simple solution is for you to change the name of cookie according to the folder, before of session_start(). In doing so, you have fully independent but…
-
4
votes2
answers524
viewsA: Problem storing data in Array
Basically there’s no way the code can work a miracle and show you something you’re not saving anywhere. When you do that: $_SESSION['lista_tarefas'] = $_GET['nome']; is changing the variable for a…
-
13
votes1
answer2093
viewsA: How to display error while query?
The usual way is: $inserir2 = mysqli_query( $link, $sql ) or die( mysqli_error( $link ) ); If you need something more elaborate, you can get the error code and its description: $inserir2 =…
-
2
votes1
answer152
viewsA: Variables in friendly Urls
The problem is that you are completely discarding the query string in its rewrite. One way out is to capture what comes after ? and include in redirect, something like that: RewriteRule…
-
1
votes1
answer52
viewsA: What is the best way (including frameworks) to work with JSON files? Using Javascript
JS Puro To browsers modern, just use the JSON.parse var json = '{"result":true,"count":1}', obj = JSON.parse(json); alert(obj.count); See the supported browsers: http://caniuse.com/json jQuery To…