Posts by Francisco • 7,472 points
260 posts
-
0
votes1
answer3585
viewsA: Confirm registration by sending email
Your problem is that in the file resgistar.php, you are checking a variable that was not created. To fix, change: if($result) For: if($resultado_registo)…
-
8
votes1
answer2284
viewsQ: How does Bag of Words work and where does it use it?
I have recently researched on artificial intelligence and found some articles talking about such a "bag of words", but I don’t know what it is and I didn’t find anything in Portuguese talking about…
artificial-intelligenceasked Francisco 7,472 -
1
votes1
answer383
viewsQ: What are the advantages and disadvantages of using object-oriented mysqli?
I’ve always used the mysqli the way I found most practical and never noticed any differences. Then came the question: why use the mysqli object-oriented? What are its advantages and disadvantages?…
-
0
votes3
answers498
viewsA: search email in the database and make it appear in a select with php
You can do this simply using the mysqli_fetch_row() of mysqli. <?php $connect = mysqli_connect('localhost','bancodados','senha', 'root'); //Infos do BD $comando = "SELECT email FROM professor";…
-
0
votes3
answers33
viewsA: Print at the top of the page
If it appears only where it calls, you can try to make a gambiarra to call it indirectly. <NAV BAR / CABEÇALHO> function resultado ($nota) { echo "Sua nota foi tal:".$nota; } function…
-
1
votes2
answers40
viewsA: How to sort the position of a matrix automatically?
You don’t necessarily need to create another variable, you can use it and override the values: $matriz = array_values($matriz); If you will always take only the first value of the array, the…
-
0
votes1
answer71
viewsA: Vector exercise, do I need help?
The problem is you’re overreacting to values. To solve, you can set the i like 5, hence it would begin to define the variables from the 5th vector. for (int i = 5; i < 16; i++) {…
-
3
votes2
answers91
viewsQ: How to make the code not catch the ASCII Code from a variable?
I’m having a problem trying to add numbers that are in a variable, because it’s taking the ASCII Code from the same. How do I directly pick the number that is within a variable? string bin =…
-
2
votes1
answer714
viewsA: How to read text files?
You can simply put all the lines in an array and then make one foreach. No need for a StreamReader. string[] lines = File.ReadAllLines("workers.txt"); foreach (string line in lines) {…
-
4
votes2
answers287
viewsQ: How to add methods to a native class?
How to add functions in a native C#class, in my case I tried to do in System.Math only as a test: public class Math { public static double test(double a) { return a; } } And call it that:…
-
10
votes1
answer107
viewsA: Condition to check null variables does not work
You can try this 3 ways. 1st Way: <%If IsNull(textocontrato) Then%> 2nd way: <%If (textocontrato) == null Then%> //Note que null não tem aspas 3rd Way: <%If (textocontrato) == ""…
-
2
votes1
answer1810
viewsA: How to add lines manually in a datagriedview populated with Mysql data
You should instantiate a column before, recommend creating a function for this. private void button1_Click(object sender, EventArgs e) { Hide(); CriarRow(/*DataSource usada*/);…
-
0
votes3
answers79
viewsA: What would the conversion of this algorithm look like from c to c#?
A tip: The code is very poorly written, I recommend doing with arrays, but ok. I translated it to C# for you, just copy and paste. public static void Main() { double soma=0, media; double a, b, c,…
-
4
votes2
answers2341
viewsA: Get name through user ID
You have to run the query and read the returned value, to do this, this way: $select = "SELECT nome FROM usuario WHERE id_usuario = '$id_usuario'"; $resultado = mysqli_query($connect, $select); row…
-
0
votes3
answers664
viewsA: How do I upload all the files in the directory except for a specific one?
Make the normal addition and ask for a rewind of the config.php. git add -u git reset -- config.php
-
0
votes1
answer29
viewsA: I need some help with the database
You can do this easily in Phpmyadmin, I made an example, copy it the way it is. To change the PAGAR for PAGO, do: UPDATE tabela SET Pagamento='PAGO' WHERE id='1'; Where tabela you complete with your…
-
1
votes2
answers756
viewsA: Creating a regex for vowels in C
You can do this by comparing each char of your array, in this way: int testvogal(char p); int main(void) { char regex[] = "algoritmo"; int t = 0; char final[99]; for (int i=0;i<strlen(regex);i++)…
-
3
votes4
answers294
viewsA: Replace character by PHP function
You can use the substring php, thus: $conta = "5149.3074*{{INPUT}}^(0.0001)-5129.6906"; $primeiro = strpos($conta, "("); $segundo = strpos($conta, ")"); $valor = substr($conta, $primeiro + 1,…
-
1
votes2
answers325
viewsA: Getsqlvaluestring / mysqli_real_escape_string / Notice: Undefined variable: mysqli
Exchange the mysql for mysqli, I believe it’s a misspelling of yours. Would look like this: $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($mysqli, $theValue) :…
-
1
votes1
answer110
viewsA: I’m having trouble with Undefined index
The problem is that you are requiring variables from $_POST without first instating them. For example: You created your form and sent the information by the method $_POST to the page index.php, that…
-
0
votes2
answers109
viewsA: Launch Exception with error #1452 - Cannot add or update a Child Row: a Foreign key Constraint fails
He doesn’t make mistakes because the MySqli does not return a Exception in the same way as php. To capture an error from Mysqli, you can create a function and call it if the query gives error.…
-
4
votes1
answer574
viewsA: Percentage in the result
The code is correct. See working on Ideone. For rounding the result, you can use the round(), in this way: s+=str(round(Result3))+"%" And to write you the result: print (s) #Normalmente.…
-
0
votes1
answer59
viewsA: Problem with MYSQL + PHP Database
What are you doing here $mysqli=query() is instantiating a variable called mysql and assigning the returned function value query(), which I believe does not exist in your program. To fix try this…
-
3
votes1
answer303
viewsA: Tic-tac-toe in C. The program ends before
The cont variable had not been started and its if was very wrong. I fixed it for you, just copy and paste. I also recommend doing a check function, not to get so big the condition. #include…
-
1
votes2
answers261
viewsA: Translate mysql_query to PDO "UPDATE * SET... WHERE..."
To connect to the database and select it: $sql = new PDO('mysql:host=localhost;dbname=banco', "user", "pass"); To execute the query: sql->query(UPDATE tabela SET lat='$lat1', lon='$lon1',…
-
0
votes1
answer100
viewsA: I need to convert a string to int within an hql
As LINQ said, you are trying to convert the string "SELECT Km_Atual FROM Rota WHERE Id=LAST_INSERT_ID()" instead of the value the database will return. To do this you will need to make a connection…
-
0
votes2
answers199
viewsA: code implementation
In your case, you put your whole code in main, which is functional, but it’s wrong. To join the 2 codes, you can create a method in your friend’s code with your entire code and call from the switch.…
-
1
votes2
answers132
viewsA: Permanent focus on a field - WPF
You can use the event LostFocus textbox. private void textBox1_LostFocus(object sender, EventArgs e) { this.ActiveControl = textBox1; } Note that I used the name textBox1 only as an example.…
-
1
votes2
answers40
viewsA: Pull the information last information you will use for comparison
The problem of using the LAST_INSERT_ID(), is that it only returns the value of AUTO_INCREMENT of your table, in your case the id, but if you still wanted to use it, it would look like this: SELECT…
-
0
votes1
answer47
viewsA: I need to take the patient id from the table to the next page, along with the user, by clicking the button
You can do this using the method ?_GET, would look this way: <td><a href='sala_questionario.php?id=$row['id']'><button class='btn…
-
1
votes2
answers102
viewsA: Fix error game
What is happening is that you asked to show life only when x is 0, and the problem is that when you get the answer right, x goes to 1 and never goes back to 0. To solve, just turn x to 0 at the end…
-
5
votes2
answers7350
viewsA: error when conver string to float in python
As I told you in the comment, the problem is that Python does not recognize the comma (,) as a representation of decimals, only the point (.), you can reverse this by using the replace, as Fabius…
-
1
votes1
answer68
viewsA: Separate data in table
Just add an extra column, huh? How would it look: ALTER TABLE estatisticas ADD COLUMN 'temporada' INT(1) NOT NULL FIRST; And when you go to select: SELECT * FROM estatisticas ORDER BY temporada ASC;…
-
1
votes1
answer94
viewsA: Control number of user accesses in Windows Forms
You can create a column in your database of type boolean for when it is logged in. Adding the table: ALTER TABLE tabela_usuarios ADD 'logado' boolean; To put Boolean as true When you open the form,…
-
1
votes2
answers1212
viewsA: How to use and what is the timer function in C#?
Okay, let’s go to your sample code. Timer t = new Timer(TimerCallback, null, 0, 2000); The first parameter (TimerCallback) you are calling the function private static void TimerCallback(Object o) to…
-
1
votes3
answers1380
viewsA: How to print an HTML using PHP a <ul> list of items with 3 different types?
I made only the first so you see how it would work, the rest you can do alone, my purpose is not to do for you and it shows you how to do. <?php $select = "SELECT * FROM plans WHERE idplans=1";…
-
3
votes1
answer100
viewsQ: Why is the Zipfile function not working?
I found a function on MSDN that I’m needing to use for a program that I’m doing. My problem is that when I try to use it, it appears as if it didn’t exist in C#, remembering that I have already…
-
3
votes1
answer79
viewsA: How to compare directory path names?
You can do it this way: string caminho = "C:\\anacarvalho\\Database\\Updates\\2017\\2017_04\20170419_AC"; string raiz = "C:\\anacarvalho\\Database\\Updates"; if (caminho.Contains(raiz)) { //Código…
-
2
votes2
answers92
viewsA: Value conversion
Try this way: string hql = "SELECT p.Km_Atual FROM Rota WHERE p.Km_Atual as LAST_INSERT_ID(Km_Atual)"; SqlCommand cmd = new SqlCommand(hql, conn); //conn é a string da conexão. conn.Open(); km_t =…
-
0
votes1
answer44
viewsA: How do I add a value to my database?
To redeem only 1 value, you do not necessarily need to use Reset, da para pegar direto do ExecuteScalar();. To insert the getid(), would have to do an update, the way I did, see if it fits you well.…
-
3
votes3
answers3142
viewsA: Select Sum in table with PHP/Mysql
To make the check: $select = "SELECT hora,COALESCE(SUM(qtd), 0) FROM table WHERE data='2017-06-07' GROUP BY hora"; //No caso coloquei a hora e data que você utilizou no seu exemplo, mas teria que…
-
0
votes1
answer557
viewsA: Compare Textbox with field in a Sqlserver table
Try this way: SqlDataReader reader = comand.ExecuteReader(); //Executa o leitor if (reader.read()) { if (txtCodigo.Text == reader[0].ToString()) //[0] é a primeira coluna que o select irá retornar,…
-
0
votes1
answer938
viewsA: display data from a mysql database column under label
In this your code, since you want only one value returned, you can do it directly by Executescalar. It would look like this (I took your code as a base): MySqlConnection conexao = new…
-
11
votes6
answers1056
viewsQ: How to make a Split for when there is a letter in the string?
I’d like to make one string be divided with the .Split() every time there was a letter. Example: To string: 97A96D112A109X115T114H122D118Y128 Would become a array with 9 values: { 97 96 112 109 115…
-
0
votes1
answer44
viewsQ: Problem with for and string. Remove
I’m having a problem with a program that I did for encryption and decryption from a hash, don’t judge how it works, I did it while it was very tied. What is not working is the Decrypt, I believe it…
-
0
votes1
answer67
viewsQ: How to stop a windows Forms application until a form is closed?
I want when Form1 is opened, the whole program stops, and only comes back when it is closed. How can I do this? Code that opens Form1: if (x == DialogResult.Yes) { Form1 f1 = new Form1(); f1.Show();…
-
0
votes1
answer90
viewsQ: Why doesn’t it work on my user control?
I have a code that would like to put it in the user control of my windows Forms, but it does not make changes to Form1, what is the reason? Code: private void button5_Click(object sender, EventArgs…
-
3
votes3
answers11315
views -
2
votes2
answers442
viewsA: Is it possible to create mobile games with just c#?
The best way to do this with C# would be with the Unity, which is made especially for games and features mobile support. Another way would be with the Xamarin, but I would say that is not the best…
-
2
votes3
answers1453
viewsA: Calling form after loading screen
Simple, just do it: private void timer1_Tick(object sender, EventArgs e) { if (progressBar1.Value < 100) { progressBar1.Value = progressBar1.Value +2; } else if (progressBar1.Value == 100) {…