Posts by Edilson • 5,207 points
158 posts
-
1
votes2
answers912
viewsA: Reading user information
Hello, as already mentioned in the above answer, Console.Read() reads the next character typed, its code actually, and for what you want, you would need to know the equivalent of those characters to…
-
1
votes2
answers110
viewsA: Doubt using array
Hello. // inicializacao da matriz int[][] array = new int[3][5]; // inicializar a segunda linha, terceira coluna com o valor int 20 array[1][4] = 20; For all the case, array[0] identifies the first…
-
7
votes2
answers971
viewsA: Are there static methods in Python?
Using the @staticmethod: class Exemplo(object): @staticmethod def soma(x,y): return x+y def subtrai(x,y): return x-y print(Exemplo.soma(2,2));…
-
0
votes2
answers411
viewsA: How to load autoload classes on web and local server
DEFINE('DS', DIRECTORY_SEPARATOR); DEFINE('ROOT', dirname(__FILE__)); DEFINE('PUBLIC_PATH', ROOT . DS . 'public'); DEFINE('PRIVATE_PATH', ROOT . DS . 'private'); DEFINE('LIB_PATH', PRIVATE_PATH . DS…
-
3
votes1
answer449
viewsA: How does the communication between classes work from client/user requests in MVC?
As others have said in the comments, the MVC It’s not technology, it’s just a way of organizing the project, separating into various logical parts that interact with each other forming the system.…
-
1
votes3
answers10624
viewsA: Success message after filling the form with HTML and PHP
For simple cases, use sessions, there’s nothing simpler like this. After checking all the information on the log page, set a session variable with index erro or sucesso: if(confirmado):…
-
2
votes2
answers299
viewsA: AJAX javascript, PHP post does not work
Is missing the url, and define the header: ... var url = "receberFicheiro.php"; ajax.open("post", url, "true"); ajax.setRequestHeader("Content-type", "multipart/form-data"); ajax.onreadystatechange…
-
1
votes2
answers3306
viewsA: Fatal error: Call to a Member Function fetch_array() on Boolean when querying Function help
Use braces { to work with variables inside quotes: $sql = "SELECT cat_nome FROM cat WHERE cat_id = '{$cat}'"; Or you can do this too: $sql = "SELECT cat_nome FROM cat WHERE cat_id = '". $cat . "'";…
-
2
votes3
answers5861
viewsA: How to style an echo with CSS?
Since the echo allows multiple parameters, can be used as follows: First form (quotation marks and commas): echo "<div class=\"saldo\">", number_format($saldo, 2, ',', '.') ,"</div>";…
-
2
votes1
answer254
viewsA: PHP PDO does not insert value
$stmt->execute(); $sql = 'INSERT INTO teste (codigo, nome) VALUES (:codigo, :nome)'; $stmt = $this->con->prepare($sql); $codigo = 1; $nome = 'teste'; $stmt->bindValue(':codigo',…
-
8
votes2
answers1109
viewsA: Number divided by a divisor greater than it returns zero?
Integer division, returns integer. Make one of them to be of the type float: val = float(1) / 16 print(val); #saida: 0.0625 Or it forces the change in the behavior of the operator / to be the same…
-
6
votes3
answers10473
viewsA: Check if the number is Javascript prime
Do so: <html> <head> <meta charset='utf-8'/> <title></title> </head> <body> <p> <input type="text" id='name'/> </p> <input…
javascriptanswered Edilson 5,207 -
2
votes2
answers100
viewsA: Click detection and value collection
You can just use the forEach or any other repeating structure to traverse the elements present in the selection. And since you already have the class name, the ul is unnecessary: var generalPanel =…
-
2
votes3
answers88
viewsA: Merge array as PHP
Even using the array_merge, you’ll always lose one of them, the best you can do is get something like this using the array_merge_recursive: array_merge_recursive($el1, $el2); #saida:…
-
3
votes2
answers3746
views -
2
votes2
answers141
viewsA: Handling and Error Handling
Something really practical and recommended is to make use of ternary operators along with the functions isset and empty as in @rray’s reply, to prevent the reading of non-existent indexes. Something…
-
4
votes4
answers100
viewsA: function_exists fatal error
If you’re gonna work with methods (class properties), the same ideal is to use method_exists instead of function_exists. <?php class A { static function mostra(){ return; } private function…
-
2
votes2
answers1275
viewsA: Explanation of login and profile validation code
There are reasons why you may think there are unnecessary things there, but it would also be right to think that necessary things are missing. You could do it like this: <?php session_start();…
-
3
votes2
answers2037
viewsA: Pass an array of objects via AJAX via POST and read the properties of objects in PHP
Assign a reference to the data you want to send pedido, and remove header setting contentType: 'application/json'. $.ajax({ url: "../actions/rota_inserir.php", type: "post", data: {pedido:…
-
3
votes1
answer68
viewsA: What is the most recommended and performative way to manipulate dates in PHP?
The best way, depends on what your application requires, because both the functions data, strtime as the class DateTime are qualified. If it is oriented then it uses classes, if not, it uses the…
-
1
votes1
answer118
viewsA: How to make a C routine run and do not stop until I execute a command?
You can use the kbhit: do { puts("c"); } while(!kbhit()); The only problem is that it doesn’t work on all compilers. examples of use on other compilers: examples…
-
1
votes1
answer2417
viewsA: File upload, write MYSQL name and path
Start by modifying the table arquivo with the following command: alter table file Modify id int(11) not null auto_increment; With this you add the attribute auto_increment at the table. In a…
-
5
votes3
answers1870
viewsA: What is metadata for HTML documents?
Simply put, metadata is data that provides information about other data, or data about data as says wikipedia. If you understand programming you can easily associate this to the concept of arrays…
-
1
votes1
answer136
viewsA: What problem, I can’t get the list to the other function?
What are you passing on to the split not a string, is the very list: >>> type(textos) <class 'list'> Put this list on a loop and capture the words from there: def separa_sentencas():…
python-3.xanswered Edilson 5,207 -
0
votes1
answer190
viewsA: How to put a variable alert in the onclick parameter of a link? using jquery and php
You can just do it like this: ... while($verp = mysql_fetch_array($sqlp)){ if($rs['disponivel']){ $estado = "inactivo"; } else { $estado = "activo"; } print "<a href=\"#\" name=\"{$rs['cod']}\"…
-
3
votes4
answers8807
viewsA: How to insert a property into a javascript object?
You can put both objects together like this: data2 = { "desColigada": "Empresa fulano de tal", "codMatricula": "00555454", "dataImpressao": "23/05/2016" }; arrayInformacoes = [ { Data: "Mar 20, 2017…
-
3
votes1
answer3593
viewsA: How to compare a string of an array in C?
Problems: Using the wrong function to read the string. It is not comparing the string, but the address where it is. Little space in the matrix. Not iterating as often as necessary. Starts by…
-
6
votes6
answers1694
viewsA: Why not use a Boolean parameter?
Why is it bad ? Because, as some have already mentioned, it nullifies the principle of cohesion, where functions with only one purpose, begin to perform two or more tasks than those originally…
-
3
votes1
answer10388
viewsA: How to present only negative values in C?
You just need to check if the number is higher or lower than 0. void negativo_print(int a); void positivo_print(int a); int main(int argc, char *argv[]) { int a, b, c; puts("Digite o primeiro…
-
2
votes2
answers560
viewsA: Values from one form to another
You can try that 1st Form : form.html <body> <form action="formB.html" method="get"> Name: <input type="text" name="nome"> <input id="submit_button" type="submit" value="PAGINA…
-
1
votes1
answer1038
viewsA: Error inserting data into Mysql table
Some of the data are poorly formatted since it is received from the form, and others are by poor definition in table attributes reservar. Using this code here, you can solve the problem: <?php…
-
0
votes3
answers758
viewsA: How to add a number with a string
Do so: var mao1 = "Carlos1"; var mao2 = 1; var mao3 = mao1.replace(/[0-9]/, parseInt(mao1.match(/[0-9]/)) + mao2);
javascriptanswered Edilson 5,207 -
3
votes3
answers2111
viewsA: Comparing C string contents to find palindrome
here you are forgetting the index 0, in this case you are always counting +1 character Voce is also using the strlen, which is a function of the library <string. h> to solve, subtract -1 here…
-
3
votes3
answers1974
viewsA: How to add more products?
For security reasons, I recommend using a Framework own to create virtual stores, because they offer greater security, create stores in this way, is usually for people who already have knowledge in…
-
1
votes2
answers289
viewsA: Validate max_size on an input type="file" with JS
Do so: <input type="file" name="photo" id="photo" onchange="verificar(this);" /> And you can rewrite the function that way, without having to resort to the event onchange all the time. And to…
-
4
votes2
answers130
viewsA: Why the program is terminated before the scanf
Double quotes instead of single. if (s != "y") { op = 0; } Do it: if (s != 'y') { op = 0; } When you want to read one character you can always use the getchar() which is specifically made for these…
-
2
votes3
answers2116
viewsA: How to rewrite a URL?
For you, the solution would be this one demonstrated, but because I do not know exactly what the structure of your table is, I will base myself on the details provided in the comments. Although you…
-
1
votes2
answers365
viewsA: Why do browsers render the same page in different ways?
The fact that many browsers adopt different rendering mechanisms makes it one of the main reasons for this to happen, let’s see for example: In some browsers for example, the text fonts used are not…
-
4
votes2
answers435
viewsA: What characterizes a database?
Database, as its name suggests, it is an organized structure, capable of retaining information, and allowing this same information to be retrieved, providing specific mechanisms capable of boosting…
-
1
votes1
answer211
viewsA: How to use Friendly Urls to create download link
Something very simple, to have a minimum sense of what you really need to do, is this: <?php // index.php // apresentar os respectivos links print "<a href=\"download/{$item['chave']}\"…
-
3
votes3
answers287
viewsA: Do you need to use the third bind* parameter?
When you use one of these constants at the end of that method, is the same as applying a validation filter, or simply processing the data, which transforms the value into an appropriate type of…
-
1
votes3
answers408
views -
4
votes1
answer735
viewsA: password_hash or crypt, which brings more security?
The simplest way to explain the existing difference is to say that both have different patterns, and one allows more algorithms than the other, which sometimes vary according to the system in use,…
-
5
votes1
answer652
viewsA: How to use a variable within another method of the same class?
You are using OOP remember which options best fit when you’re going to solve scope problems. class Title extends Imoveis { private $extension; public function file_verify($file) { $file =…
-
2
votes1
answer536
viewsA: Safe way to use PDO?
In addition to what I said in the comments, I would like to add that writing scripts in procedural form using the PDO, It can be a little more complicated if you’re using related functions. In the…
-
17
votes1
answer2146
viewsQ: What is a chain of methods?
In object-oriented languages, there is a concept known as method chaining or encadeamento de métodos to Portuguese. What exactly is this ? How would be the implementation of this technique in a PHP…
-
3
votes3
answers252
viewsA: Use of preg_replace invalidates password with SHA1
It is obvious that the question has already been answered, but to supplement the comments, «Do not use sha1 to encrypt passwords», simply because it doesn’t protect you. To handle validations, I…
-
2
votes2
answers322
viewsA: Why can’t I use $this within a Static class?
Basically you can’t use $this directly in static methods because they are not directly connected to objects or instances of the class, while non-static methods always refer to objects or instances…
-
6
votes4
answers4957
viewsA: Call static class method by static variable
As has already been said, self, exists only within the class, such as the parent. The self is used to reference static members of that same class, while the Parent references methods that this class…
-
6
votes2
answers1800
viewsA: Can I use "Cin" and "getline" in the same code?
Where have you got this: cout << "\n\nDigite o nome do funcionário: "; getline (cin,nomeFuncionario); Place this, to run that line while it is not filled. cout << "\n\nDigite o nome do…