Posts by Daniel Omine • 19,666 points
581 posts
-
7
votes4
answers8677
viewsA: What’s the difference between data and information?
Reinforcing what they have already answered, We have here the letter To. This letter is a given. There is no clear context about what it represents so it is just a given. Now we have the lyrics To…
terminologyanswered Daniel Omine 19,666 -
1
votes1
answer470
viewsA: Query Table versus View Table: What is the best practice?
Views are roughly a summary for some query you’ll need to use in different scripts. This facilitates maintenance, for example, when you need to modify something, you would only modify it in the view…
-
3
votes2
answers2875
viewsA: When should I use disabled, read-only or hidden fields?
I don’t know any rule that says you have to do X or Y. Nor would it make sense to have a rule that dictates how to do it. This is the developer’s free choice by observing the usability of the…
-
0
votes1
answer129
viewsA: Dynamic update with variable check $_POST
Getting the column name of a table $result = mysqli_query("SHOW COLUMNS FROM nome_da_tabela"); while ($row = mysqli_fetch_assoc($result)) { $data[] = $row; } print_r($data); Set the values From now…
phpanswered Daniel Omine 19,666 -
1
votes2
answers485
viewsA: Cities and states in XML or Mysql
Regarding performance, any database query consumes more resources than simply reading a file. If you want a simple and straightforward answer, yes, within the context of what you described in the…
-
0
votes5
answers50
viewsA: How to change the end of a name
Example with str_ireplace() $str = 'あTON, いCON, うTON'; echo str_ireplace(array('con,', 'ton,'), array('com', 'tom'), $str.','); note: It will work if the original string always has the same pattern…
-
4
votes3
answers493
viewsA: Is it bad practice to fill <select> <option></option> with data from the database?
It is not feasible to determine whether there is bad practice in the presented code. The question is vague and creates a disconnected sense. Something closer to "bad practice" may be the style used…
-
1
votes1
answer270
viewsA: Upload Image to Hostinger directory
That "include" doesn’t seem to make sense: file_put_contents(include($_SERVER['DOCUMENT_ROOT']."/public_html/imagens/fotos_func/TESTE.jpg"), imageDecodificada); Remove:…
phpanswered Daniel Omine 19,666 -
0
votes2
answers377
viewsA: Error reading XML file
The link is accessible and loads normally. Probably your server’s IP may be blocked. There is nothing to do in this case, except contact the administration of the site.
-
1
votes3
answers107
viewsA: validation of superglobal
In the code you presented there is no bad practice. A bad practice would be to sanitize or filter the data of the superglobal. Example of what would be a bad practice: $_POST['foo'] =…
-
1
votes3
answers93
viewsA: Error in declarations with Array
Short array syntax was introduced in version 5.4. In lower versions is issued syntax error. Behold: http://php.net/manual/en/migration54.new-features.php It’s still early to use the shorthand []…
-
6
votes3
answers1491
viewsA: Is it good practice to use composite keys as the primary key?
Good practices exist to prevent future problems. They are recommended by those who go through experiences that others might someday experience. Usually something inevitable. When it becomes…
-
2
votes2
answers376
viewsA: Static method calling an object
As of version 5.4, STRICT error is issued for the presented case. If you are not seeing error messages on the screen may be due to the error report settings. If you’re using PHP version 5.4 or…
-
3
votes4
answers5899
viewsA: PHP ask for confirmation before deleting
Suggestion of how to do if (mysqli_affected_rows($conn) != 0) { echo "<META HTTP-EQUIV=REFRESH CONTENT = '0;URL=../../paginas/layout/dashboard.php?link=12'> <script…
-
1
votes2
answers3239
viewsA: Decrease the size of a file(image) in PHP
It is not possible to manipulate the image on the client side within the context of the question. Plugin One option would be to install some plugin in the client’s browser and then through this…
phpanswered Daniel Omine 19,666 -
6
votes2
answers312
viewsA: Is it possible to define a class within an array in earlier versions of PHP 7?
The code you posted is instantiating a anonymous class. Anonymous classes introduced in PHP7. Regardless of being using array, it will not work in lower versions. I lower two options, distinct from…
phpanswered Daniel Omine 19,666 -
2
votes2
answers63
viewsA: Operator Bitwise Right
Dividend is 4 and the divisor is 64. In the expression is reversed. The right then is 4 / 64, whose result is 0.0625
-
4
votes2
answers3923
viewsA: Run parallel process in PHP
A routine that executes processes in the background: class Background { /* $cmd -> A linha de comando a executar. $opt -> Opção de parâmetros para o ambiente onde executa o script. */ public…
-
2
votes7
answers11400
viewsA: How to validate phone in php
If you want to let the user enter the number freely and apply sanitization: // número que o usuário digitou $n = '(11) 456-456-4567'; // faz um cast para o tipo numérico inteiro. // isso quer dizer…
-
2
votes2
answers1283
viewsA: How to exchange values of two variables without using a third one in php
Given the conditions, the most appropriate form would be using XOR Swap algorithm. That is, the same that you presented in the question using bit-by-bit operators. However, to function as desired,…
-
1
votes3
answers3129
viewsA: How to list the properties of an object in php using foreach?
In the code you posted, the properties are set to private. To list these properties would have to create a public method where would then be made such a foreach and the return of the result.…
-
6
votes1
answer1974
viewsA: var_dump returns everything on the same line
You are probably viewing through the browser. Brower renders HTML. The output of var_dump() returns in plain text. In plain text, the line break is r or n. The browser does not render line break. To…
-
1
votes1
answer470
viewsA: Site with backslash on localhost
I believe that part of the problem is in this section: define("SITE_PATH", __DIR__ . '/'); define("SITE_VIRTUAL_DIR", str_replace($_SERVER["DOCUMENT_ROOT"], "", SITE_PATH)); The name…
phpanswered Daniel Omine 19,666 -
3
votes2
answers3374
viewsA: Modify foreign key for auto-increment
You can run this directly in the sql query: ALTER TABLE tableName MODIFY COLUMN column name INT(6) auto_increment Obviously, you need to change the names in bold. The excerpt INT(6), change the…
-
7
votes2
answers115
viewsA: Converting two Mysql selects to one
You can do something like this: $sql = 'select T1.* from tabela1 as T1 LEFT JOIN tabela2 AS T2 ON T2.tabela2_estrangeira = T1.tabela1_codigo'; I did something generic because JOIN can be the right…
-
1
votes2
answers1982
viewsA: Access files outside public_html
Static files must be in the public folder or "Document root". Otherwise, that is, the way you want to maintain the structure of files and directories, you would have to make a stream or a scheme…
-
10
votes4
answers2583
viewsA: Can PHP’s unset() function improve performance?
It depends on the context because if it is misapplied cause opposite effect, increasing the use of memory and processing. See a simple test: Test 1 Here we use unset() to remove variable indexes…
-
6
votes2
answers339
viewsA: Is it possible to create a "synonym" of a function, two names for the same function?
From PHP 5.6 there is a new feature to create an alias http://docs.php.net/manual/en/migration56.new-features.php#migration56.new-Features.use Example: use function minhaapi as ma; For earlier…
phpanswered Daniel Omine 19,666 -
1
votes1
answer47
viewsA: Set FROM different from the email you are actually sending. Is it safe?
As you may have noticed, yes, it is possible to send normally. However, it is currently bad practice because email servers are blocking as a basic security issue. Try, for example, sending an email…
-
0
votes2
answers182
viewsA: Object Life Time in PHP - How many Controller instances?
HTTP is a stateless protocol. Briefly it means that each request is an independent transaction. The whole process in PHP is compiled at runtime and "dies" when the build is complete. In a second…
-
13
votes2
answers3546
viewsA: How does a computer understand binary code?
Supplementing the subject, In a general summary, for those who are floating, the binary code logic is 0 -> off 1 -> connected. Modern computing The first "modern computers" organized data in…
-
1
votes1
answer585
viewsA: Split table into 4 columns with PHP
<?php $total_dias = date("t", mktime(0,0,0,date('m'),'01',date('Y'))); $l = 4; // quantidade de colunas $c = 1; // contador auxiliar for($dia = 1; $dia<= $total_dias; $dia++){ if($dia <=…
-
0
votes2
answers224
viewsA: MYSQL NOT IN array php
Looking at the surface, one notices the lack of the delimiter. implode("", $csv[$i]) swap for implode("', '", $csv[$i]) Tip Before executing the query, check the integrity by breakpoint: right after…
phpanswered Daniel Omine 19,666 -
2
votes1
answer138
viewsA: How to Submit Another Page Form
It is not allowed to execute scripts or gain access to HTML objects under a different domain. For example, if you run a Javascript action from www.foo.bar to access elements of www.bar.foo, you will…
javascriptanswered Daniel Omine 19,666 -
1
votes1
answer34
viewsA: How to check the domain you are in
The global variable $_SERVER contains the information you need. The current domain can be obtained in the index HTTP_HOST or SERVER_NAME. Note that it is data that depends on the settings of the…
phpanswered Daniel Omine 19,666 -
2
votes5
answers2278
viewsA: Is it safe to use $_GET in PHP? (Parameter in URL)
Introducing The purpose of this answer is just to clarify and put things on track. Regarding the processing of data to make a request or sending data secure, the 4 existing answers, up to the date…
-
4
votes1
answer347
viewsA: PHP - Pushing an array within another array
$data = array( "login1" => "login1", "login2" => "login2" ); function json($message, $data) { echo json_encode(array('message' => $message, 'data' => $data)); } json("teste", $data); I…
-
6
votes3
answers3191
viewsA: Should I use the «or die»?
I believe it is a bad practice inherited from basic language lessons. The first tutorials of PHP with Mysql, including the official manual, show examples of connection with Mysql as the one posted…
phpanswered Daniel Omine 19,666 -
6
votes3
answers1080
viewsA: One process at a time PHP
That seems very simple. According to what you described in the question, I don’t think you need threads, queues, etc. Just create a flag. When to run processo.php create a flag that identifies you…
-
0
votes3
answers2199
viewsA: Offline and online PHP application
Summary It is impossible to answer because there are several ways to solve and there is no way to determine which technique is best suited to your specific case. To determine you need to make a…
-
2
votes1
answer47
viewsA: Am I validating twice?
Yes, it is redundant. You could apply the cast once. The name of this is sanitization (Sanitize). After sanitizing, filter and validate. Example $var = (int)$var; // Faz o cast para numérico inteiro…
-
3
votes1
answer4700
viewsA: Parser error : Start tag expected, '<' not found
This error message is typically caused by bad XML formatting. Check whether the contents of $transaction contains a valid XML string. To test, in this section $transaction =…
-
1
votes2
answers1458
viewsA: Limit the size of an array
Simple $teste['nome'] = $array['nome']; $teste['snome'] = $array['snome']; Using the function array_slice() $array = array('nome' => 'foo', 'snome' => 'bar', 'test' => 'ok');…
phpanswered Daniel Omine 19,666 -
5
votes1
answer11955
viewsA: JSON return with special characters in URL
Quick fix. Just copy and paste. You don’t have to use your brain very much. while ($r = mysql_fetch_assoc($result)){ $linhas[] = $r; } echo json_encode($linhas); Trade it in and it’s all quiet!…
-
1
votes3
answers97
viewsA: Check the existence of the values of one array in the Keys of another
I think I’d do something as simple as that: $keys = array( 0 => array( '{3}', '{1}', '{2}', '{5}' ), ); $arr = array( 0 => array( 0 => 'foo 0', 1 => 'foo 1', 2 => 'foo 2', 3 =>…
-
0
votes3
answers496
viewsA: email with a disfigured table
In internal table 1, in the first <td>, is declaring colspan=2 needlessly. Some renderers can interpret literally and others just ignore. When interpreted literally, rendering adds cells that…
-
0
votes1
answer220
viewsA: Directory error with spl_autoload_register
The constant __DIR__ returns the current file directory, from the file where script is being executed. In your case, /home/neowix/public_html/erp/pages/classes/autoload.php When mounting the path to…
phpanswered Daniel Omine 19,666 -
3
votes2
answers3050
viewsA: Is it possible to have a ternary without the Else block?
Translating the question code for a ternary condition: $total_gerente = (($total < 10)? 10: null); Recommended to delimit the condition with parentheses to avoid problems with syntax errors.…
-
2
votes2
answers1234
viewsA: Use more than one H1?
In a very concise and objective way, yes, you can use it more than once. H1 only defines the level of importance of the title. If the page contains, for example, a call for 5 articles, usually each…
html5answered Daniel Omine 19,666 -
3
votes1
answer71
viewsA: Case sensitive MYSQL
In the Mysql settings file, set the parameter lower_case_table_names worthwhile 2. Example: lower_case_table_names=2 If no parameter exists, acidify it. After the changes, save the file and restart…
mysqlanswered Daniel Omine 19,666