Posts by Adir Kuhn • 2,342 points
69 posts
-
0
votes1
answer65
viewsA: ob_start(): Second array Member is not a Valid method
what that function does eh compress the contents in gz to be sent to the customer. Turns out this call is not correct: ob_start(array('ob_gzhandler',5)); I believe that the original intention was to…
-
1
votes2
answers54
views -
1
votes3
answers82
viewsA: I’m not displaying the multiple correctly
Mano na real the statement ta claro has 2 int the first is the number that you need to find the multiple, the second is the bounder of the multiple, that is you have to find the largest multiple and…
-
0
votes3
answers67
viewsA: Regex is not working with file_get_contents
Good by default PCRE treats the string as a single line, but even so I believe it should marry the result of its regexp. Try using the multiline modifier and see if you can get some results.…
-
-2
votes3
answers574
viewsA: SLIM FRAMEWORK - 404 PAGE NOT FOUND
To be honest the code is not very good but try to make these changes $app->get( '/login/', function () use ($app) { require_once("login.php"); } ); ... if($total == 1){ $_SESSION['login'] =…
-
4
votes2
answers212
viewsA: Creating buffers in PHP
As I mentioned in the comments the solution of using string to mount the package is wrong, because if you convert a number to string it will be treated as string by PHP then the int(40) that should…
-
0
votes1
answer106
viewsA: Time difference in units
There is no parameter to format in this form. Take the minute difference and divide by 60. Then add the time difference <?php $inicio = new DateTime("10:00"); $fim = new DateTime("11:30");…
-
2
votes2
answers474
viewsA: Incomplete week name on strftime return
PHP removes locale information from the operating system it is running on. As described in the documentation: Note: The setlocale() return value depends on the system on which the PHP is running. It…
-
1
votes1
answer133
viewsA: What are the causes that cause a php Session to expire?
You have to change the parameter session.cookie_lifetime more information on PHP website Update: Try to increase as well session.gc_maxlifetime ex. ini_set('session.gc_maxlifetime', 3600);…
-
0
votes1
answer79
viewsA: Override PL-SQL condition
The right thing would be for you to check before if there’s a doctor’s code (:medico) and then insert the condition. But that should do it, in case you don’t get it by the first option (NVL) where…
-
2
votes1
answer105
viewsA: Select Betweeen in data Cakephp
You have to pass these filters in the same array public function comprasMes(){ $condicoes = array( 'conditions' => $this->params->params['condicoes'], 'order' =>…
-
3
votes2
answers381
viewsA: Reading JSON result with PHP
The problem is that collection2 will become an array (at least in the example of this URL you passed) Then try to scroll through this array Ex. <?php $result =…
-
0
votes3
answers182
viewsA: Is there any way to put Input automatically?
The most practical answer is yes. You can throw the inputs you need into a TXT file and read into the program. If you are using Linux from to use an input redirect. A very crude example: Suppose you…
-
5
votes4
answers2688
viewsA: How to add the ninth digit, fixed, using jQuery Mask?
From what I saw in the documentation it is not possible to force with the options of the plugin but you can use a placeholder to indicate the format and use a fallback to force the entry of the…
-
1
votes2
answers3938
viewsA: Calculation with decimal number PHP
The problem is that we use the comma as the decimal separator , in PHP the decimal separator is the point . That said you have N ways to solve your problem, since bring those numbers formatted with…
-
2
votes3
answers161
viewsA: This Javascript loop is taking down my browser. Any idea why?
As already said was the problem of the counter always increment what left the loop "infinite" I changed the algorithm to use regular expressions function RunLength(str) { var r = ''; while…
-
0
votes1
answer2283
viewsA: How to turn an integer into decimal?
Something like that? <?php $a = 15; $b = $a / 10; //1,5 $c = floor($b); //1 - arredonda para baixo var_dump($a, $b, $c); //para você verificar a transformação do número echo number_format($c, 1,…
-
3
votes2
answers395
viewsA: How to verify if a constant exists in the class or in a namespace?
you can use the function defined but don’t forget to pass the class name together <?php namespace StackOverflow { const LANG = 'pt-br'; class StackOverflow { const MY_CONSTANT = 'minha…
-
2
votes5
answers580
viewsA: Doubt in SQL query "between" or "in"
Do so (if php and mysql) WHERE STR_TO_DATE(CONCAT_WS('-', v.verba_ano, v.verba_mes), "%Y-%m") BETWEEN STR_TO_DATE('{$ano}-{$mes}', "%Y-%m") AND STR_TO_DATE('{$ano_fim}-{$mes_fim}', "%Y-%m")…
-
1
votes2
answers2835
viewsA: Send html page variable to another page using javascript
One solution is to use the local storage (local storage) as described here. For example: //Escrever um valor localStorage.fruta = 'banana'; //Exibir o valor armazenado…
-
2
votes2
answers466
viewsA: Find out which table the data is from, in a Union
as far as I know does not give but you can bring the table name within the result of each row, something like this: SELECT id, batata, outro_campo, 'tabela1' FROM tabela1 UNION SELECT id, pao_de,…
-
0
votes4
answers120
viewsA: Error using variables in a query
you have to put the string in quotes and escape to avoid error in PHP $user_info = "INSERT INTO 'mytable' ( `NOME`, `DESC` ) VALUES ( \"$nome\", \"$descricao\" )";
-
3
votes1
answer82
viewsA: Unexpected result in C program
You are not starting variable x here: int x, y = 10; should be int x = 10, y = 10;
-
2
votes2
answers1736
viewsA: How to separate array in odd/even and calculate multiple number?
Even or odd check is correct. To round to multiples of 10 you can do so: <?php function round_multiple10_up($num) { $mod = $num % 10; if ($mod !== 0) return (10 - $mod) + $num; return $num; }…
-
1
votes1
answer333
viewsA: Select all elements of an array in a variable with Regex in PHP
Try to use the preg_replace_callback something like this: <?php function adicionaTexto($matches) { return '<li class="inciso">' . $matches[0]; } $documento = file_get_contents($arquivo);…
-
1
votes4
answers20245
viewsA: PDO:: Fetch & Fetchall
Why the data structure is different from a look at the documentation of the fetch and of fetchAll you will see the difference. Basically get used to using the print_r or the var_dump to see the…
-
0
votes3
answers2209
viewsA: map in C works?
As already suggested the best is to implement its map in that case. I can recommend the use of hash table and the use of that lib to C. Take a look too in that article which explains about hash…
-
3
votes2
answers538
viewsA: Why omit the PHP closing tag?
As quoted in the PHP manual itself http://php.net/manual/en/language.basic-syntax.instruction-separation.php The closing tag of a PHP block at the end of a file is optional, and in some cases…
-
1
votes2
answers1731
viewsA: PHP Graphical Interface
Normally in PHP it is used as a web language and for this the development of screens is done using HTML and CSS, you can find several tutorials on the net about this. If that’s the case I recommend…
-
2
votes2
answers325
viewsA: How to return all installments in this function in [PHP]?
You cannot return 11 values at once with Return, an alternative is to calculate all the plots in a separate array and return that array, another is to put another attribute in the function that will…
-
3
votes5
answers4587
viewsA: How to remove ddd from a number
It has several forms. One possibility would be to substate $numero = substr($numero, 2); So it takes the first two characters from the string
-
4
votes2
answers612
viewsA: Regex to select only numbers from 1 to 2,000
from 1 to 2023 \b(\d{1,3}|1\d{1,3}|20[01][0-9]|202[0-3])\b https://regex101.com/r/pK1jE5/1 from 1 to 2000 \b(\d{1,3}|1\d{1,3}|2000)\b REGEX are used to match patterns in the case of mine with…
-
1
votes1
answer52
viewsA: Display links in sql query
There are several ways to do this recommend using serialize/unserialize. <?php $sites = array( 'www.google.com', 'www.terra.com.br', 'www.globo.com' ); $serializado = serialize($sites); $lista =…
-
1
votes2
answers1198
viewsA: Make an algorithm to calculate the number of days elapsed between two dates
You can use Datetime for this <?php $dia1 = "12"; $mes1 = "02"; $ano1 = "2011"; $dia2 = "20"; $mes2 = "02"; $ano2 = "2013"; $data1 = DateTime::createFromFormat("dmY", $dia1 . $mes1 . $ano1);…
-
3
votes3
answers2472
viewsA: Generate single random value with php
You can do it like this: <?php function id_unico() { return uniqid("A"); } More information about uniqid http://php.net/manual/en/function.uniqid.php Example: http://ideone.com/GLfKLp…
-
2
votes1
answer569
viewsA: How to free access to Public folder
The first rule already does not need the RewriteCond Public... RewriteEngine On RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f…
-
2
votes1
answer393
viewsA: preg_replace PHP - / or @ why put?
No difference, serves only to indicate the beginning (delimiters) and end of your regex Update: Only in case you want to marry a '@' then you would have to escape using the delimiters @ ex. @\@@ or…
-
0
votes1
answer808
viewsA: Create a start and end period with a list of days
I didn’t understand it very well. You want to separate the dates when the difference of days is greater than "1" is this? If it is I did this function see if it meets you: (http://ideone.com/0B7hCC)…
-
1
votes2
answers860
viewsA: Help with PHP Stack
To access the methods you must use the arrow '->' and not the point '.'. Another thing is the method __isset it is a method of isset call overloading for that class, ie when I call isset($classe)…
-
1
votes2
answers696
viewsA: fwrite in a certain PHP line
You can do something like this: <?php $file = $arquivo_destino; $line_looking = 16; //lembre que a contagem começa em 0 $lines = file($file, FILE_IGNORE_NEW_LINES); $lines[$line_looking] = 'Linha…
-
8
votes1
answer1604
viewsA: How to concatenate an SQL command into a Mysql Stored Procedure?
I think something like this should solve your problem: CREATE PROCEDURE batata(node CHAR(30)) BEGIN DECLARE segmentos INT; DECLARE jump INT; DECLARE contador INT; SET segmentos = LENGTH(node) / 3;…
-
2
votes3
answers389
views -
4
votes3
answers3283
viewsA: Regular expression for dates without tab
Try this (0[1-9]|[1-2][0-9]|3[0-1])(0[1-9]|1[0-2])(199[0-9]|200[0-9]|201[0-9]|2020) Being Dias (0[1-9]|[1-2][0-9]|3[0-1]) Mes (0[1-9]|1[0-2]) Ano (199[0-9]|200[0-9]|201[0-9]|2020) Only problem is…
-
1
votes1
answer110
viewsA: Update database by SQL PHP
In fact you are not changing the data with this query, it will update all the weight records by itself $sql = mysqli_query($conexao, "UPDATE aluno SET peso = peso WHERE nome=nome"); You have to…
-
2
votes1
answer552
viewsA: Insert data into mysql, commit() does not work
I believe that it is because it is lost the reference of the variable being treated, try so ve se da import MySQLdb def conn(): try: db =…
-
4
votes2
answers5857
viewsA: How to break a string
Something like that? function Quebra (input: String; separador: String) : TStringList var resultado: TStringList begin resultado := TStringList.Create; resultado.Delimiter := separador;…
-
2
votes1
answer139
viewsA: Associative array or object to save temporal meta-data?
It goes from the taste of the customer, there is no correct form in this aspect, the best form is the one that serves you. Just try to maintain consistency, if your application has been implemented…
-
1
votes3
answers436
viewsA: Why is array_shift considered a slow function?
The function becomes slow precisely reindexation of the elements, in its graphic it is very clear that the greater the number of elements in the array the longer the execution time. And in my view…
-
1
votes3
answers163
viewsA: SELECT filtering the first results
To do this is easier programming. Make a normal select with the items you want and then check if the field is yes and remove resultados = query(Select.... Contador = 0 Para Cada resultado Em…
-
2
votes2
answers256
views