Posts by Francisco • 7,472 points
260 posts
-
0
votes1
answer360
viewsQ: Error trying to create a new Mysql table
I am encountering an error while trying to create a table in my database in Mysql. I read about this error in other occurrences here in stackoverflow, and it seems that it occurs when you try to use…
-
15
votes6
answers751
viewsA: Numbers and your friends
C# (míseros 5.120 bytes) Many Bytes! But what matters is that it’s working! hahaha Code: using System;class Program{static void Main(string[] args){int N = 1500; for (int n = 2; n < N;…
-
26
votes6
answers751
viewsQ: Numbers and your friends
The sum of all natural numbers (positive integer) of divisors 220 except 220 is equal to: 1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284 And the sum of all natural numbers of divisors 284…
-
0
votes3
answers650
viewsA: How to copy a data snippet from a string?
I believe the best way to do that is with Regex, see how it would look: string[] arr = Regex.Split(valores, @"(?=STX)"); arr = arr.Where(x => !string.IsNullOrEmpty(x)).ToArray();…
-
1
votes3
answers1640
viewsA: Datetime function C#
Okay, this is the code: Console.WriteLine(DateTime.Parse(Console.ReadLine()).ToString("HH:mm:ss")); Now let’s break it into pieces and see what each command does and how it works: Console.ReadLine()…
-
1
votes1
answer3707
viewsQ: What is the best way to generate random code that does not repeat in the database?
I need to generate a random code of 5 characters, can not have repetitions. I managed to do as follows: function testarcode($code){ global $link; if ($code == ""){ return false; } $comando = "SELECT…
-
6
votes1
answer62
viewsA: How to check if it already exists in the comic book?
The problem is that you wrote different table names, I believe one of them doesn’t even exist: //Primeiro comando "SELECT * from recebescores where red='$red' AND green='$green' AND black='$black"…
-
0
votes1
answer531
viewsA: Error trying to log into localhost by Phpmyadmin
Search for the file config.inc.php which probably should be in C:\wamp64\apps\phpmyadmin4.6.4 and open it with some text editor. Note: Be careful not to confuse with a file called…
phpmyadminanswered Francisco 7,472 -
0
votes1
answer531
viewsQ: Error trying to log into localhost by Phpmyadmin
I am trying to connect to my local database and am getting the following errors: #1045 - Access denied for user 'root'@'187.20.253.86' (using password: NO) mysqli_real_connect(): (HY000/1045):…
phpmyadminasked Francisco 7,472 -
3
votes1
answer2546
viewsA: Parse error: syntax error, Unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or Identifier (T_STRING) or variable (T_VARIABLE) or
I believe the problem is that it is not identifying the variables correctly. Try passing them using concatenation: $inserir = $conexao->query("INSERT INTO cadastro (nome, sobrenome, email, senha,…
-
2
votes1
answer95
viewsA: error when zeroing a string
This is not a mistake! The problem is in: scanf("%s", nome_lab); Are you using the %s, it only keeps until the first white space, ie if you have strings with white spaces, better not use it. Try it…
-
1
votes1
answer404
viewsA: Contact form for PHP
First you must configure the form so that it can send the data somewhere: <form action="algumapagina.php" method="post"> //Action é a pagina para qual o formulario vai enviar e methos como ele…
-
3
votes1
answer403
viewsQ: How to get the same strcpy() result with strcpy_s()?
I downloaded a C++ code from the internet and when I open the solution, the following error: Error C4996 'strcpy': This Function or variable may be unsafe. Consider using strcpy_s Instead. To…
-
0
votes1
answer400
viewsA: How to email the content written in a <textarea></textarea>?
You can take the value of <textarea> by the method POST of Form, example: <form method="post" action="query.php"> <textarea name="texto"></textarea> <input type="submit"…
-
1
votes2
answers385
viewsA: Send blank field to database
You can do a simple check for this by declaring the variable $mensagem: $mensagem = $_POST["mensagem2"] == "" ? $_POST["mensagem2"] : "Sem Mensagem";
-
1
votes1
answer412
viewsA: Parse error: syntax error, Unexpected '}' in C: xampp htdocs network-social index.php on line 15
Your problem is that you didn’t close all the if properly, closing even more than it should, and forgetting to open some. The solution is very basic, just look at the openings and the closures:…
-
0
votes1
answer54
viewsA: Error in database connection
You are not running the Insert query, only the select query. Let’s go to the table test: $sql = "insert into usuarios(usuario, email, senha) values ('$usuario','$email','$senha')"; //Criou a string…
-
0
votes1
answer249
viewsA: Wait for an event to be triggered to continue the C#
You do this using the AutoResetEvent, to expect a response from the method _WebBrowserDocumentCompleted. static AutoResetEvent esperar = new AutoResetEvent(true); //Instancia o AutoResetEvent…
-
2
votes3
answers1548
viewsA: Find pair and odd in variable float language C
Floating point number does not provide accuracy, then its equality occurs in some cases, but not in the majority. That’s just one of the reasons why you can’t use it for monetary value. No…
-
4
votes3
answers634
viewsQ: How to make my program consume less CPU without disturbing its execution?
I have a program that reads the memory of a computer process continuously (with the while (true)), but it ends up requiring a lot of CPU, arriving at 20% used, my question is, how to decrease CPU…
-
0
votes3
answers43
viewsA: Registering form in the Database
Instead of using the null, to use a predefined value (auto_increment), use the default. And from what you told me, your table is made that way: cod int primary key auto_increment, manga varchar(50),…
-
3
votes1
answer6085
viewsA: Rename entire Mysql Database
Phpmyadmin has an operation for this. In Phpmyadmin, select the database you want to rename. In the tabs, there is a call Operations, after that, go to the rename section. Or, create a new database…
-
8
votes2
answers3402
viewsA: Error: Not all code paths return a value
The error happens because you are not explicitly returning anything. To fix it, I recommend you create a variable to do the return: public Conta LoginCliente( String Agencia, String Conta) { Conta…
-
0
votes2
answers59
viewsQ: How to get elements from a different page?
I’m creating a system to take the first 4 paragraphs of a particular Wikipedia page and paste them into div id="txtTextoResposta" of the page the user is, however the problem I am having, is that I…
javascriptasked Francisco 7,472 -
4
votes1
answer2524
viewsA: How to adjust Select size in Bootstrap?
You can use CSS width to fix this. #comboEstabelecimento{ width:auto; } <h3>Selecione o Estabelecimento:</h3> <select class="form-control" id="comboEstabelecimento"> <option…
bootstrap-3answered Francisco 7,472 -
5
votes2
answers72
viewsA: What’s wrong with this PHP code?
I don’t think you need to put the echo, try to do it that way: $out = array('success'=>false,'error'=>'You dont have coins! You have'.$user['xxx']); Also try double quotes instead of single…
-
1
votes2
answers108
viewsQ: If you are not checking the condition correctly
I was trying to make a very basic little program to know if a variable had a second decimal place or not. However I came across a "bug", which in my view is bizarre. Code: #include <stdio.h>…
-
1
votes1
answer33
viewsA: E-mail Notice/Report
Use the function mail(): <?php $opt = $_POST['opcoes']; $titulo = $_POST['titulo2']; $cap = $_POST['capitulo2']; //Pessoa que vai receber o email $destinatario = "[email protected]"; //Assunto…
-
4
votes1
answer386
viewsQ: Is it possible for a program to modify its own code?
I was developing an artificial intelligence program with neural networks, but what always left me chained is that every time I open the program, it will have to repeat the entire learning path to…
-
1
votes2
answers994
viewsQ: How to read Console strings?
I’m trying to make a code that reads a string from Console browser and assign the string value in id "txtTextoResposta". To make it more illustrated, I want to make it similar to C#, when we do like…
-
0
votes1
answer197
viewsA: Accent code page in Command Prompt
Try using the code page 65001: chcp 65001
-
0
votes3
answers238
viewsA: Error while trying to overload Operators with dates
If I understand your question correctly, you want the "/" on each item on the date. To do this, you must format your text: std::put_time(&date, "%d/%m/%Y");…
-
0
votes1
answer48
viewsQ: C# is not finding/recognizing my List
I have a List made with the following code: List<frase> frases = new List<frase>(); According to the documentation of System.Collections.Generic, my code is right. But for some reason C#…
-
0
votes2
answers1521
viewsA: Test for prime number
No, this is a terrible way to do it. I found this on the Internet, it’s more functional: #include <stdio.h> int main() { int n, i, flag = 0; printf("Escreva um numero positivo: ");…
-
3
votes2
answers166
viewsA: Parse error in code
You put all the code inside a string and the if with the capital "I". To fix, just put the "(aspas) at the end of the string you want and exchange the If for if: <?php include("db.php");…
-
2
votes1
answer180
viewsA: UNDEFINED VARIABLE ERROR
What is happening is that you are declaring the variable $stringMascaraBin within the function if, then it won’t work outside of it, unless you define it as a global variable. To fix, set the…
-
0
votes1
answer83
viewsA: Error trying to register
Try turning the columns to the class Rota using the Transform of nhibernate, in this way: IQuery query = session.CreateSQLQuery(hql).TransformUsing(Transformers.AliasToBean<Rota>());…
-
1
votes2
answers99
viewsA: I’m having trouble reading a string inside a function
Your code actually has several errors, the 2 clearest ones are: You cannot send a pointer to a method that you ask for an integer value as a parameter: Where did you put: cadastro(livros, &i);…
-
2
votes1
answer71
viewsA: How to break line between php tags with css
I don’t know where you got it from, but <br> is not obsolete. Example of use in your code: <figcaption> <?php echo $tiporesultado."<br>"; ?> <?php echo…
-
1
votes1
answer547
viewsA: Emailing a C#application
If I’m not mistaken, you need a server SMTP, I believe the Internet has some free. Now, assuming you already have it, it’s pretty easy to send emails: //Instanciando a classe "MailMessage"…
-
6
votes2
answers140
viewsA: Is Array a C pointer?
A pointer is a special type of variable that stores addresses. If a pointer p stores the address of a variable i, we can say p points to i or p is the address of i. (In more abstract terms, it is…
-
0
votes2
answers50
viewsA: how to get the highest repetition index (source 0) within a php string
I don’t know if there is a php function to do this more practically, but I made a very simple algorithm that does this: <?php function posicaoMaiorRepeticao($x) { $index = -1; for…
-
2
votes2
answers4786
viewsA: how do I remove some numbers after the comma in PHP
One of the ways to do this is with the number_format, in this vein: number_format($valor, 2);
-
1
votes1
answer25
viewsA: Concatenate an SQL value
Your problem is that you are setting the value of est_quantidade for the value of vQntP, to make a junction of the two, you must make a sum, in this way: update est_matprim set est_quantidade =…
-
0
votes2
answers46
viewsA: How to join edit/new button?
I recommend checking already within SQL, with the INSERT ... ON DUPLICATE KEY UPDATE. $query = "INSERT INTO Medicos (nome, NIF, telemovel, data_nascimento, email, morada , observacoes,…
-
1
votes1
answer2632
viewsA: How to resolve "Can’t connect to Mysql server on" error?
This is a privilege issue, meaning you are not allowed to access this database. If the server is yours, you can use this command line to secure the privileges: mysql> CREATE USER…
-
0
votes3
answers2459
viewsA: Doubt SQL Working Days Query
I didn’t quite understand that function you said you had, I tried to do it in the simplest way possible. SELECT YEAR(dias_uteis) AS 'Ano', MONTH(dias_uteis) AS 'Mes', dias_uteis AS 'Dias Uteis' FROM…
-
2
votes2
answers157
viewsA: If I declare a variable in a SELECT query is it required?
I recommend doing this directly to php. You can use a if to do this, as Stéfano suggested, or in a more simplified way: $sql = empty($nome) ? "SELECT * FROM clientes" : "SELECT * FROM clientes WHERE…
-
1
votes1
answer497
viewsA: Manipulate Printscreen in C#
You will need 2 libraries: using System.Drawing; using System.Drawing.Imaging; And to take the screenshot: private void PrintScreen() { Bitmap printscreen = new…
-
10
votes1
answer2284
viewsA: How does Bag of Words work and where does it use it?
Explanation The model bag-of-words is a simplified representation used in natural language processing and in the information retrieval (IR). In this template, a text (such as a sentence or a…
artificial-intelligenceanswered Francisco 7,472