Posts by Inkeliz • 20,671 points
671 posts
-
0
votes1
answer49
viewsA: Rule for selecting records based on date and time
By the structure you are using the DATETIME in partida.data_hora. If you use: date(partida.data_hora) >= date(now()) Is ensuring that the year, month and day will be longer and equal to the…
-
5
votes3
answers630
viewsA: Check if there is tag within site
Another way would be using Domdocument from PHP, especially for those who don’t like REGEX. :P Get the source code: $ch = curl_init('http://seu_site_alvo.com'); curl_setopt_array($ch, […
-
0
votes1
answer42
viewsA: CRSF protection when deleting multiple AJAX items
The protection of CSSF is to prevent another website and other software, such as mobile apps, from making a request on behalf of the user, in short. For example:…
-
23
votes2
answers10069
viewsA: When and why use session_start?
A session is what identifies the user. The function of the session_start uses a file located in the temporary folder, (/tmp/) by the name of sess_*. The * is the same value as cookie (PHPSESSID)…
-
1
votes2
answers980
viewsA: How to find (and capture) the user running PHP?
You can use the $_SERVER['USER']. If a person accessed site.com/.php file, the $_SERVER['USER'] would be the nginx, for example. While running, via SSH (php /www/.php file) it would be the…
-
6
votes4
answers366
viewsQ: What’s the difference in using sprintf in relation to using variables within the string?
Seeing some libraries and examples is common find the sprintf in some situations where I find it strange. Reading your documentation I noticed that there are several types of formatting, however I…
-
1
votes2
answers1197
viewsA: how to insert data into two tables at the same time
The problem is similar to what I answered this question. The difference is you’re not using procedural mode, but come on. First you create the connection: $link = new mysqli ("localhost", "root",…
-
5
votes1
answer656
viewsA: Error trying to log in PHP
There are several small mistakes... 1. mysqli_select_db() Are you using as mysqli_select_db('treinamentos', $conexao) and in fact it is the other way around, according to the documentation it is…
-
7
votes1
answer5767
viewsA: How to select with an array?
You can use the IN. If the array is: $array = ['Trabalho', 'Jantar', 'Casa', 'Fora']; You need to pass this to a string, in order to stay: "Trabalho","Jantar","Casa","Fora" That way you can use…
-
0
votes1
answer48
viewsA: Gnupg returns false in PHP
I got a solution. D Cause of the problem: PHP/NGINX was unable to access the folder where the file is imported and so was presented false. Try running the same script as root using the PHP-CLI and…
-
1
votes1
answer48
viewsQ: Gnupg returns false in PHP
I’m using the module Gnupg in PHP and tested exactly with this code: $keydata = '-----BEGIN PGP PRIVATE KEY BLOCK----- Version: BCPG C# v1.6.1.0…
-
3
votes2
answers10959
viewsA: How to select between dates
It depends on the format that is in your database. If it is in format DATETIME: Use DATE(): SELECT * FROM Tabela WHERE Status = 1 AND DATE(Data) > '2017-01-01' AND DATE(Data) < '2017-01-17'…
-
2
votes0
answers182
viewsQ: Engine with lower RAM consumption than Innodb/Xtradb in Mariadb?
Innodb allows you to make several INSERT and also UPDATE without creating LOCKING, while in Myisam it is not possible to make several INSERT at the same time and to make matters worse Myisam does…
-
3
votes4
answers1609
viewsA: Mysqli_fetch_row() expects Parameter 1 to be mysqli_result
There are two errors: 1. Variable $conn: The mysqli_fetch_row() awaits the outcome of mysqli_query(), mysqli_store_result() or mysqli_use_result(), see here in the documentation, and not the…
-
0
votes1
answer57
viewsA: How to set to default value all PHP settings?
You just need to get the original file, which can be obtained here, is too long to be published here at Stackoverflow. Within Plesk there must be some "advanced" location to change PHP.ini settings,…
-
3
votes3
answers201
viewsA: What’s wrong with my script? - setTimeOut
On the console (F12) you can see that the problem is: Uncaught SyntaxError: Unexpected identifier The setTimeout expects the first parameter to be a function or a string of code, see here:…
javascriptanswered Inkeliz 20,671 -
8
votes3
answers20580
viewsA: Close modal bootstrap automatically when send form
You can use the modal('hide'). $('#seu_modal').modal('hide'); This can be performed within the success. Example: $('.abrir').on('click', function(){ $('.modal').modal('show'); });…
-
7
votes3
answers1777
viewsA: PHP picking up Cloudflare IP instead of user IP
Does anyone know why this happens? This is because Cloudflare acts as a proxy, the user connects to a nearest Cloudflare server, and then Cloudflare connects to your server, if necessary, because…
-
2
votes3
answers52
viewsA: Character manipulation in PHP
This is a variation of @Miguel’s response: You can use this: $nome = 'joao.silvestre'; $final = $nome[0].substr(explode('.', $nome)[1], 0, 7); It works in PHP 5.5 and above, unless mistakenly.…
-
1
votes3
answers1601
viewsA: Help me with the "Undefined index: referrer in " PHP error
You must use isset(), which is the most common and the fastest. But, you can also use the array_key_exists() to verify that the array index has been defined and is valid. In this case I could use:…
-
2
votes2
answers1672
viewsA: Rotation of photos in PHP
You can use the function imagerotate(). For example: // Define o básico $graus = 90; $arquivo = "imagem.jpg"; // Cria a imagem de JPEG (se for PNG deve usar imagecreatefrompng(), por exemplo)…
-
1
votes1
answer47
viewsA: Difficulty handling the query
You can use in general: SELECT ( ( SUM( IF(respostaaluno = respostacorreta, 1, 0) ) / COUNT(id) ) * 10 ) as Media FROM Respostas GROUP BY `ra` See this by clicking here. Explanation:…
-
1
votes1
answer94
viewsQ: Group continuous repeats with Mysql
I was wondering if there is any way to group repetitions using Mysql only. If you make a SELECT * from tabela WHERE id_usuario = 1 ORDER BY id ASC will return: id | id_usuario | Data | Texto 0 | 1 |…
-
0
votes1
answer241
viewsA: Creating a custom domain for customers like Icasei does
This has nothing to do with Nginx, at least it can be done without any relation to the nginx. This could be a note from CNAME in DNS. Having possession of the ronaldocarol.com.br you create a CNAME…
-
6
votes2
answers833
viewsA: Change the quality of online video?
When you upload a video to Youtube it detects the quality of the uploaded version, the uploaded video will be the highest quality available, the lower qualities will be rendered by Youtube. By…
-
5
votes1
answer92
viewsA: PHP displays error "Failed to write Session data" at random times
I discovered the problem, which was one of the things I suspected but I didn’t think it was the problem. I use some vulnerability testing software, although they do not accuse errors I started to…
-
1
votes1
answer92
viewsQ: PHP displays error "Failed to write Session data" at random times
I have a website that is fully functional and the failure rate is 0.0037%, however all errors are the same. Unknown: Failed to write session data (files). Please verify that the current setting of…
-
1
votes3
answers623
viewsA: White bar at the top of wordpress
Quite possibly this is because one of the files (not necessarily the header) is with the UTF-8 BOM, see this other case at Stackoverflow. Unfortunately removing this will depend on the editor you…
-
5
votes1
answer834
viewsA: Problem with Curl, catch message body even with http != 200
The problem is exactly in the third line. curl_setopt( $ch, CURLOPT_FAILONERROR, true ); According to the documentation of CURL: A long Parameter set to 1 Tells the library to fail the request if…
-
1
votes2
answers1266
viewsA: Login within javascript Alert
This is not exactly "an Alert login", but a login via HTTP Basic Authentication; Specifically this screenshot appears to be from an authentication of HTTP Basic Authentication, can even login…
-
0
votes2
answers24
viewsA: HOW to Replace Data Between Table
You can user INSERT INTO SELECT INSERT INTO tb_macsliberados (`mac`, `idDoMac`) SELECT `mac`, `idDoMac` FROM tb_mac WHERE idDoMac = "1" In this case it will "move", actually insert all the data that…
-
0
votes2
answers420
viewsA: Store New Value by Updating Old Value
I recommend you leave the work with Mysql, using TRIGGERS That way you can do something like: CREATE TRIGGER `nome_trigger` BEFORE UPDATE ON `tabela` FOR EACH ROW SET SaldoAnterior = OLD.Saldo…
-
2
votes2
answers630
viewsA: Allow multiple requests from the same PHP user
Probably this occurs because of the SESSION or TRANSACTION. PHP does not in any way limit the number of simultaneous connections (NGINX, Apache or extensions or other firewalls, can even). 1.…
-
4
votes1
answer129
viewsA: Replace text when value is not NULL
Depends on what you call null. The Stock comment is correct, you simply use the comparison: if($valor !== null){ // Substitui porque não está nulo }else{ // Está nulo } However there is a difference…
-
0
votes2
answers865
viewsA: How to view image without an extension via direct link in the browser?
This answer is because you have the [PHP] tag on the question. With PHP: You can enter the Header in PHP: header('Content-type: image/png'); The document type will vary, so you should define the…
-
2
votes1
answer888
viewsA: Customize the Nginx error message
All errors can be modified. First create a file and give a name, for example: 500.html. I’ll put this in the directory /usr/share/nginx/error/, this will prevent you from accessing the…
-
1
votes1
answer56
viewsA: Doubt about loading images in CSS
Depends on the browser. Some browsers can locate all images, including those not used on the page. This has a positive side, after all the desktop user can resize the window, for example, so the…
-
2
votes1
answer155
viewsQ: Ajax Polling shared between tabs
First of all I need to inform the current situation. I own a website, there is an ajax Polling, which requests every 5 seconds to get notifications and the like. The entire site is supported by two…
-
7
votes1
answer3311
viewsA: How to play a. mp3 file in PHP
In fact you are not "playing a . mp3 in php", I believe that to achieve this the player itself should be built in PHP, I don’t even know if there’s such a thing. But I understand what you mean. Your…
-
2
votes1
answer107
viewsQ: Update FTP without the file being removed while overwriting
The FTP Whenever you send a file it is unusable for a few milliseconds, until the entire file is in place. The problem of this is that the file for a few milliseconds does not exist or is corrupted,…
-
4
votes5
answers426
viewsA: Explodes with name indexes (associative)
This answer is based on comment from @stderr! You can use the list (take the example "Using list() with array indices"). $user = "Diego:25:RJ"; list($info['nome'], $info['idade'], $info['estado']) =…
-
2
votes3
answers316
viewsA: Separate values from a string and execute a function with the same
What you want is to make a loop, there are various and various ways of doing this and various topics about it here. If the string holds: (DDD)|(NUMERO)\n, each \n you will have a (DDD)|(NUMERO),…
-
0
votes1
answer43
viewsA: I would like to know how I can sub-select domains for my newsletter?
Actually what you want is to "add a suffix per line", regardless of being any data to be inserted. To enter a suffix/prefix just take the current value, then "add" the string the data to be…
-
4
votes2
answers443
viewsA: The "pay()" function does not return the correct result
The problem is much more mathematical than programming. Moreover the question is not clear about the problem, making it almost a service outsourcing. But as it is easy and simple to solve I will…
-
1
votes2
answers3869
viewsA: Skip line Javascript
Just make sure the .val() is divisible by how much you want to break the line (42 in your case), then enter a \n, using .val($(this).val()+"\n") as an example. You should remove breaks from previous…
-
2
votes1
answer1470
viewsA: Find content within two html tags - Regex
You can use the DOMDocument to filter through H2. You didn’t report HTML, so imagine this: <div id="content"> <h2>Blog</h2> <p class="y">Isto é um blog</p>…
-
4
votes2
answers59
viewsA: How to turn the first array of a multidimensional array into a key?
You can use the array_map for this situation: $array_nomes[] = ['Guilherme', '32132', '123456', '987654321', '987654321']; $array_nomes[] = ['Paulo', '32132', '123456', '987654321', '987654321'];…
-
1
votes1
answer927
viewsA: Google Recaptcha with AJAX
You can reset captcha via Javascript. grecaptcha.reset(); Include the function grecaptcha.reset(); below the $('#contactForm').trigger("reset"); for example. This will cause Captcha to be "deleted"…
-
1
votes2
answers53
viewsA: how to structure php nodes
If you want to generate JSON, you "must" format it as array, using the indices. You can use various forms for this: Form 1: $array = ['nodes' => ["name" => "Baixo Alentejo", "color":…
-
0
votes1
answer943
viewsA: Optimize select PHP+Mysql loading
I don’t know how efficient that is! One way would be to use the cache together with the mysqli_fetch_all. PHP would be like this: $limite = filter_var($_GET['limit'], FILTER_VALIDATE_INT) &&…