Posts by João Sobral • 394 points
17 posts
-
1
votes1
answer924
viewsA: How to print a list in C?
Try to put the structure definition in the list file. h /* * lista.h * Definição da TAD Lista. */ #ifndef _LISTA_H_ #define _LISTA_H_ #include <stdbool.h> /* define a struct TAD lista */…
-
2
votes4
answers6903
viewsA: Generate random numbers that do not repeat
#include <stdio.h> #include <stdlib.h> #include <time.h> #define NUMS_NEEDED 10000 int main() { int sizeArray = 0; int i = 0, j = 0; int nums[NUMS_NEEDED]; FILE *fp = NULL; srand(…
-
1
votes2
answers211
viewsA: Error while searching in MYSQL
Your query is wrong and the function is returning false. It is always good to check after the query whether the same was done correctly. $resultado = mysqli_query($conectar,$query); if( !$resultado…
-
0
votes1
answer218
viewsA: Registration Quantity per Data Mysql
The query will return the total sales ( totalVendas ), total purchases from registered users in the previous month who purchased this month ( totalVendasCadastroAnterior ) and total purchases from…
-
0
votes1
answer1073
viewsA: How to clean temporary sessions in Apache
To remove files and subdirectories from the directory: cd /tmp rm -rf *
-
0
votes1
answer132
viewsA: Select PHP + Mysql
The problem is that you take the first query value before and do nothing, in the while it takes the value below and the first is "lost". <?php $conect = mysqli_connect( '127.0.0.1', 'root', '' );…
-
1
votes2
answers859
viewsA: Onclick type image
A function with name already exists click() in javascript, at the time it creates the attribute Handle onclick. Try changing the function name: <div class="bg-secund"> <input type="image"…
-
1
votes1
answer166
viewsA: PHP How to pick a random value like Rand($min, $max) but with a query?
Where [min] is the minimum number and [max] maximum. $select = $mysqli->query("select * from data order by rand() LIMIT [max], [min]"); This query is slow because the LIMIT will make a Sort, an…
-
3
votes2
answers335
viewsA: Javascript code does not execute prompt
The mistake is in function numero(int num) int is not required. <script> function numero(num) { return Math.round(Math.random() * num); }; var chute = prompt("Qual e o numero? "); var…
javascriptanswered João Sobral 394 -
1
votes2
answers102
viewsA: Protect Class for namespace c#
Use the modifier private, if you want the class to be visible for different assemblies, use internal.…
-
1
votes1
answer857
viewsA: Mysql error "Cannot add Foreign key Constraint"
The problem is in: Constraint ch_estr_Id_lince Foreign Key (Id_lince) References Linces (Id_lince) On Update Cascade On Delete Set Null On this line you want to set a NULL column when it is with the…
-
0
votes2
answers719
viewsA: Keyword in String C language
Do not use the function gets() because the function does not receive the size of the buffer and a buffer overflow can occur. I used fgets and your program worked, only changed a few things, but…
-
1
votes1
answer468
viewsA: Help with image uploading and viewing with $_SESSION or $_COOKIE
It is not good for you to store an entire image in a $_SESSION. Upload the image to a directory and then save the file name to $_SESSION. Here is an example. <?php //session_set_cookie_params( 0…
-
5
votes2
answers410
viewsA: Array with a text file
A solution would be to read the file line by line and add to the array: <?php $arq = fopen('arquivo.txt', 'r'); $conteudo = array(); if( $arq ) { while( ( $linha = fgets( $arq ) ) !== false ) {…
phpanswered João Sobral 394 -
2
votes1
answer54
viewsA: Problem with jQuery.ajax php
Two amendments: Use the method POST pro request because jQuery uses GET when you do not have this parameter closed I changed the query by closing the VALUES(), he was missing the last ). JS:…
-
2
votes2
answers727
viewsA: How do I add the elements of a List<string> to a listbox?
You can use the property Datasource. List<string> lista = new List<string>(); lista.Add("Nome 1"); lista.Add("Nome 2"); lista.Add("Nome 3"); listBox.DataSource = lista;…
-
0
votes2
answers1809
viewsA: How to return to the menu after performing function?
The fflush function cleans the buffer of the file passed as parameter, so you should clear the keyboard buffer before reading. #include #include char descricao[40]; void adicionar(){ FILE * pFile;…
canswered João Sobral 394