Posts by rray • 66,288 points
1,220 posts
-
5
votes2
answers1685
viewsA: How to return all fields of a "Mysql" line by the "id" of the line?
Based on the comment, to display columns in html dynamically you can use the function array_keys() that returns the key names and with them do a second foreach to display the values. $registros =[…
-
4
votes1
answer3017
viewsA: 2 Variable by header
The first element of a querystring must have a question mark ? and the other items must have a commercial and &. header ("location:…
-
1
votes1
answer31
viewsA: Friendly Urls with ten error variables
In regular expressions back or rear view mirrors has the limit of 9, when you try to access $10 or \10 apache interprets as $1, in that case it is necessary to rewrite the logic. References:…
-
5
votes1
answer104
viewsA: In PHP 7, can the class method contain a keyword name? Is that good or bad?
Globally reserved words as Property, Constant, and method Names Within classes, interfaces, and traits are now allowed. This reduces the Surface of BC breaks when new Keywords are introduced and…
-
2
votes2
answers40
viewsA: Final value of the array?
If you just want to take the key value valor of this array, use the function array_pop() it extracts and removes the last of the array passed. If you need to list each element use a foreach. $ultimo…
-
3
votes1
answer576
viewsA: str_replace generating error Array to string Conversion
The problem is that the arguments are in the wrong order, $string must be the last because it is the string to be replaced. The first argument $serach is which(ais) characters should be found,…
-
5
votes2
answers552
viewsA: How can I "skip" elements of an array when I use "list"?
The option more is to assign the first element of the array to "nothing" or to define no variable. list(, $nome, $idade) = $array; Can use array_slice() to extract the elements you want to use in…
-
4
votes1
answer93
viewsA: Get the data inside a json_decode result
It is possible to solve this problem with a regex : \w+ that capture : followed by a space and one or more characters(a-z0-9_). To access the login and password use: $m[0][1] and $m[0][2], $m[0][0]…
-
2
votes1
answer984
viewsA: Operations with Data Mysql
1064 is the sqlstate for sintexa error, in your case missed the keyword INTERVAL followed by the unit(seconds, minutes, days etc), a functional example would be this: SELECT date_sub(now(), INTERVAL…
-
4
votes2
answers293
viewsA: Insert in mysql with strtoupper not accepting numbers and letters
Another way to solve this problem is to use the function upper() Mysql so the string is already converted to Insert. Example: select upper('1c2b33cd') #1C2B33CD…
-
2
votes1
answer61
viewsA: How do I concatenate a variable into a class with Static function?
You need to pass the correct value to access the constant, in case visa is minuscule when it should be in upper case, use a function to leave the returno in upper case as strtoupper() or…
-
3
votes1
answer88
viewsA: How do I upload a php file by replacing the existing file?
This code block prevents a file with an existing name from being overwritten, it sets zero to $uploadOk which is later compared and if it is zero cancels the action if ($uploadOk == 0) {. To solve…
-
3
votes1
answer153
viewsA: Undefined variable, PHP MVC application
The problem is the scope of $errors, what happens if the code falls on the if? $error is not created/defined. if ($validation->passed()) { //logic code for this if } else { $errors =…
-
4
votes1
answer92
viewsA: What does this instruction do?
Returns a database row as an associative array and assigns to $row, recalling that the fetch() and then the assignment. while($row = $result->fetch(PDO::FETCH_ASSOC)) 2 1 3 1 - The method fetch()…
-
6
votes2
answers90
viewsA: Regular expression for number
Use the function preg_replace() to make the replacement with a regex /\d+-/, the important part is to inform the fourth argument which is the substitution number that will be made. \d+- means to…
-
0
votes1
answer189
viewsA: My client record "almost" all fields
When mounting the array to save(adicionar()) data do not use helper set_value(), values come form and to recover them use $this->input->post() there is a version for get also. Change: $data =…
-
0
votes2
answers6093
viewsA: how to test with sql Injection
mysql_num_rows() expects Parameter 1 to be Resource, Boolean Given It happens due to an error in the query, usually syntax, to say your code, first close select, add the terminator and send a new…
-
5
votes1
answer885
viewsA: What is the difference between readfile and file_get_contents?
file_get_contents() loads the entire file in memory, which can be a problem with large files. It is usually very useful when you need to handle the values returned from a file (for example, if you…
-
9
votes1
answer423
viewsA: Use CONCAT to adjust the amount of php mysql numbers
Use the function lpad() from Mysql to add a 'prefix' to the left of the string, the first argument can be the field that will be modified, the second is the length(4 characters) and the last is the…
-
1
votes1
answer558
viewsA: How to scan an array of a variable and compare with another variable?
Exchange these Ous for the use of function in_array(), it uses two arguments, the first is the string to be searched and the second the items that will be compared. <?php $texto =…
-
3
votes1
answer37
viewsA: upload does not send files after a certain size
If the uploaded files are larger than the value set by the server, changes the upload_max_filesize in php.ini with a suitable value and to finish the process restart apache. upload_max_filesize=5M…
-
1
votes2
answers1084
viewsA: Upload Multiple Codeigniter
The standard CI upload class does not allow sending multiple files, an alternative is this library and another is to use the $_FILES even. $total = count($_FILES['files']['name']); for($i=0;…
-
3
votes1
answer353
viewsA: Is there any way to discover an error occurred in json_decode?
To detect an invalid or badly formatted json use the function json_last_error_msg() for a description of the problem’s 'category'. This function is available in php5.5 or higher. $arr =…
-
2
votes3
answers63
viewsA: Perform separation on a Data Line and mount an array
There is not much secret, as the formatting of the data does not have a pattern the solution is to extract piece by piece via substring, by the intervals defined. Use the function substr() to get…
-
3
votes2
answers105
viewsA: What are dependencies in a framework for?
Dependency is a generic term indicating that the framework needs one or more libraries (classes or other artifacts) specified to function properly. For example, jquery plugins usually depend on the…
-
16
votes3
answers508
viewsA: What is a Kiddie Script?
Script kiddie is the term used for people who use scripts, source code, exploits or other types of artifacts without having the slightest notion of how they work, its use is on the basis of…
terminologyanswered rray 66,288 -
9
votes4
answers870
views -
3
votes1
answer382
viewsA: Increase amount of form inputs sent in php post
Open php.ini and change the value of max_input_vars for an appropriate number this setting defines the number of inputs sent in a request, it may be necessary to change the value of post_max_size…
-
1
votes3
answers1826
viewsA: Problems creating a login system with PHP and Mysqli
Warning: mysqli_query() expects Parameter 1 to be mysqli, null Given Your connection is not valid according to the error. Your connection variable is $connection and not $con(on the call from…
-
1
votes3
answers112
viewsA: INSERT method with PHP OO error using SQL SERVER 2012
By the question code fragments and by the comments the main problem is that the connection is not made or passed correctly to the class Autor that performs the Insert. Other problems are: The class…
-
0
votes1
answer41
viewsA: Configure localhost to display header sending warnings
You can configure the error display in two places in php.ini or directly in a file. php.ini Open the file and add or modify the line: error_reporting = E_ALL | E_STRICT This says to display all…
-
0
votes1
answer79
viewsA: Error: make a query(query) in dao which is an alias
Does not use single quotes as escape of caractares in postgres but double quotes, in this case add a bar to escape in java. sql = "select nome as \"teste?\" from pessoa where id=?"; To recover the…
-
2
votes2
answers1777
viewsA: How to force the download of a text file?
Create a new file (download.php) in it set the header to be sent or whatever format the browser should interpret the information open the file and send to the client. download php.…
-
7
votes2
answers298
viewsA: Prohibit duplicate emails in Mysql using PHP
Ensure the uniqueness of the value by adding a Unique key Constraint so the database is responsible for knowing which value is repeated or not. ALTER TABLE tabela ADD CONSTRAINT UNIQUE (coluna) To…
-
5
votes2
answers2982
viewsA: Digitalbush plugin for CNPJ and CPF masks in the same field
You can use the plugin jquery.inputmask to mask an input with different formats. The following code defines two formats the first for Cpf and the second for cnpj, when the user type the 15th the…
-
3
votes1
answer1001
viewsA: transform Mysql record into php variable and show in HTML?
The code $dados = ['nm_aluno']; may be invalid if you are using a version earlier than 5.4 php and will not do what you are imagining. An assignment(creates) is made from an array to $dados with the…
-
0
votes3
answers86
views -
3
votes2
answers2095
viewsA: CNPJ query using PHP
It’s no mistake that’s just the way out of var_dump($campos), to manipulate or display the information individually it is necessary to enter the desired index. echo 'CNPJ: '. $campos[0] . ' Nome da…
-
3
votes1
answer87
viewsA: Hide a javascript mask
Can replace the _ for nothing adding the optional argument placeholder. This is indicated in documentation of the plugin $("#ciclo").mask("9999-9999", {placeholder:" "});…
-
2
votes2
answers342
viewsA: What will be printed on the screen by this script?
In PHP a key following dollar can be the definition of a variable with strange names or its reading. What happens in the example is the value of $foo and play at reading then turns ${bar} containing…
-
0
votes1
answer377
viewsA: Relation N-to-N - How to join two fields in a Postgresql record -
To add the value of several rows in a column you can use the function string_agg() which is equivalent to Mysql group_concat SELECT livro.nome_livro, string_agg(autor.nome_autor,',') FROM livro as l…
-
0
votes1
answer5744
viewsA: Return error message for queries in PHP database
To manipulate the error returning by a query you can use exceptions or function returns (errors). Exceptions The fourth argument is an array where some settings can be passed they enter the…
-
0
votes1
answer62
views -
2
votes2
answers618
viewsA: Compare arrays
I believe that this code results in the problem, first a search is done in the array $b passing the current value of $a, case found is created a new element in $iguais who basically does the same…
-
3
votes3
answers497
viewsA: Error Search PHP and Mysql Database
Your code makes the bind of a value but no placholder(?) was passed in consultation, also jokers(% or _) in the variable with term to be searched and not in sql. The second error is caused by the…
-
1
votes4
answers912
viewsA: Add variables to obtain end date
You can do this with the method add() class Datetime combining with the class Dateinterval. What is done is adding a period determined by a string like P10D(10 days); $dataInicio =…
-
1
votes1
answer138
viewsA: Insert error in database using PDO: "Only variables should be passed by Reference"
bindParam() does not accept values or method returns only accept variables or constants, in which case it is best to exchange for bindValue() $stm->bindValue(1, $usuario->getnivel());…
-
11
votes4
answers19788
viewsA: How do I update with a Join?
Postgres does not support ansi-92 syntax of joins in the update as Mysql in your query should be done using the ansi-86 syntax which is the one where the merge is done in the clasp WHERE The…
-
4
votes1
answer172
viewsA: "Call to Undefined Function" error when calling a class function
In getData() you need to specify who is the summoner(owner) of this function(method), as in the case is the same object is used the $this Change: return convertData($this->data); To: return…
-
3
votes2
answers665
viewsA: Sum date with int
Use the function date_add() mysql SELECT DATE_FORMAT(date_add(ocorrencias.dt_fechamento, INTERVAL 50 day), '%d-%m-%Y') as calendario FROM ocorrencias Simple example: SELECT date_add(now(), INTERVAL…