Posts by rray • 66,288 points
1,220 posts
-
2
votes3
answers810
viewsA: Avoid multiple PHP Notice: Undefined index: inside a loop for
One way to solve this problem is to initialize the occurrence array with all elements already zeroed, with the function array_fill_keys() the first argument is the array that will be transformed…
-
18
votes6
answers109646
viewsA: What does the error "Script execution disabled on this system" mean?
By default the privilege to excommunicate scripts is the Restricted, ie, no script called via file can be run only in interactive mode (via console or ISE) To change the execution policy use cmdlet…
-
5
votes4
answers147
viewsA: I cannot use Boundary( b) to validate a word starting with "@"
The Fatherland (\b) applies only to letters, numbers and the underline that would be the equivalent to the \w ([a-zA-Z0-9_]) so your regex fails. In that case you would have to leave the arroba out…
-
5
votes2
answers74
viewsA: how to make this query sql
Just make a Join between the tables and specify the municipality on WHERE. SELECT count(*) FROM notafiscal as n INNER JOIN clientes as c ON n.cod_cliente = c.codigo WHERE c.municipio = 10…
-
2
votes1
answer118
viewsA: How to create a function that validates if there is a Mysql function in a given string?
If you just want to know if one or more functions exist in the string, you can mount a regex looking for the exact term with âconra \b. By placing a term between \b means you’re looking for a full…
-
8
votes4
answers4728
viewsA: How to write values to the Mysql database using PHP?
Current libs to connect to Mysql are PDO and Mysqli. Mysqli allows two types of object-oriented and function-based manipulation (such as the old and obsolete mysql_*). 1 - Create the connection The…
-
2
votes1
answer1192
viewsA: How to select a column name in Mysql?
show columns from nome_da_tabela It is simpler, this 'query' returns six fields field (what matters to you), type, null, key, default and extra. For details use the information_schema.Columns SELECT…
-
12
votes2
answers129
viewsA: Why can’t I declare an attribute as an object?
Why the public notation $object = new A(); is not correct? Because language doesn’t allow it. As says the documentation, the initialization must be the value of a constant, that is, it must be…
-
1
votes2
answers110
viewsA: Problems in using php Insert
A PDO connection does not work with the Mysqli library, so include is not right. The other problem is that it failed to pass the connection to the mysqli_query() that makes the Insert. Your…
-
2
votes1
answer3030
viewsA: What is the difference between serial and integer data types in Postgresql?
When defining a field as serial the bank creates a column of the type integer or biginteger with a sequence associated, it is responsible for increasing the number. If you create a field just like…
-
7
votes3
answers860
viewsA: how to increment letters in php?
In php you can only use the increment operator (++) in letters (the decreasing -- does not apply) as it increments the character ASCII code the valid ranges are A-Z 65-90, a-z 97-122 You can…
-
3
votes3
answers667
viewsA: Does the PHP method have line limits?
That’s a suggestion netbeans no line or character limit for a method. The ideal is that it solves only one problem or has only one responsibility. 1) A large method with all the code it needs. In…
-
0
votes2
answers222
viewsA: I’m trying to build a Megasena betting generator with the following parameters
As the numbers cannot be repeated between the cards another way to do this is to generate all the possible numbers (0 to 59) shuffle them and generate the maximum number of cards with seven numbers,…
-
13
votes2
answers91
viewsA: How to shorten the process of creating an array without the need to write all indexes?
You can create an array with certain positions using the function range(). The first argument is the number that must begin the first element and the second the maximum value. If the maximum value…
-
5
votes3
answers948
viewsA: What makes a JOIN bad in a database?
Joins are not bad except in case the query generates a product (which is combination of all rows of a table with the result set or other table). To solve the performance problem the first step is to…
-
10
votes3
answers329
viewsA: What are "code units"?
Code units are the ways instructions can be grouped. This helps in the organization and distribution/integration of a project. Some examples are functions, 'modules', classes. The term indicates the…
-
1
votes2
answers307
viewsA: How to email php checkbox results?
You can simplify the creation of the body of the email the first step is to leave all the checkbox with the same name and add square brackets. When these are sent they will be understood as an array…
-
7
votes1
answer117
viewsA: Regular expression to swap the variable pair in mysql in PHP file
You can envy the arguments by creating three groups at the end just format the substitution. The idea is to break this instruction of the following form, the first group is mysql_query the second…
-
0
votes1
answer88
views -
2
votes3
answers2636
viewsA: "Find and replace" with regular expressions in MS Word 2016
You can use the following regex ^\d+\.\d+/\d; it says to always capture at the beginning one or more digits (^\d+) followed by a point (.) followed by one or more digits (\d+) followed by a bar /…
-
5
votes2
answers7809
viewsA: How to create postgresql tables using automatic primary key id generation?
To define a column as the auto increment mysql use the type called serial or bigserial this will create a Quence that will atulizing the number to each entered record. The DDL of the table should…
postgresqlanswered rray 66,288 -
19
votes2
answers1673
viewsA: What is the purpose of : (two points) in PHP?
This is an alternative syntax for a block that is bounded by keys { }. In this case the opening turns the two points : and the closure is a end followed by the name instruction that started can be a…
-
2
votes3
answers6709
viewsA: Is it possible to have more than one Primary key in a table?
It is not possible to have more than one primary key per table, it is the column or set of columns that identify a row. To prevent repeated values from being inserted in certain columns, it makes it…
-
3
votes1
answer2964
viewsA: PHP Parse error: Invalid literal Numeric
This error happens because the number given is not a valid octal, this notation is known to have a left zero. Pass the value as a string (adding quotes) and not as a number. Change: $itau = new…
-
4
votes5
answers1513
viewsA: Skip Record within a while
Can you assemble a logic that 'deletes' the type 2 record, asking in comparison the type is different from two? In code it is like this: while($pessoa = mysqli_fetch_object($query)){…
-
1
votes1
answer69
viewsA: What is the best way to repeat the same query without copying and pasting?
The simplest way is to store the result of the query (in $row) and use it in several places. fetch() will return all the fields chosen in the query when comparing/manipulating just specify which…
-
3
votes3
answers36
viewsA: String handling at alternate positions
You can use a regex to capture the desired information: Service Id\s+:\s+\d{4,5}|MTU\s+:\s+\d{4,5} The above passage says to marry Service Id followed by one or more spaces (\s+) followed by two…
-
12
votes2
answers2108
viewsA: Are function and method the same thing?
The answer can be yes and not that depends on the context. Overall method and function are terms used to identify a named code block that can be reused in various parts of the program. More…
-
1
votes1
answer65
viewsA: Java Perspective Message
Each type of project shows certain characteristics, whenever creating or changing a project the eclipse will ask if you want to change to a suitable perspective for the project. Another situation…
-
10
votes1
answer1539
views -
0
votes1
answer91
viewsA: Why is there no result in PDO fetch Collum?
The problem is the column index to the total is 11 but as the documentation informs the count should start at zero. 0-Indexed number of the column you Wish to Retrieve from the Row. If no value is…
-
0
votes1
answer126
viewsA: Recovers values using classes and Pdo without going through the url
First need to hit your query, or you named place holders that are those have two dots followed by an ex name: :id or place holders that are the questions. Change: $sqlId = "SELECT * FROM web_cadcli…
-
3
votes1
answer59
viewsA: Select with YEAR and MONTH together
Yes it is possible, use the function date_format() passing the desired format in place of the two functions. Y for the 4-digit year and m for the month with two digits. SELECT SUM(valor) FROM contas…
-
0
votes1
answer93
viewsA: Resize array
If the breakdown of the index sequence is the problem as in the code below: <?php $cesta = array("laranja", "banana", "melancia", "morango"); unset($cesta[1]); $cesta[] = "novo"; You can create a…
-
4
votes2
answers66
viewsA: What is the purpose of & in PHP?
The & serves to assign or modify a variable by reference. $b = &$a It means every time $a is alerado $b will have the same value as $b always points to $a. If the value $b change $a will…
-
2
votes2
answers45
viewsA: Error in SQL output
Just as in mathematics you need to tell which operation has the highest priority, this is done through parentheses. Your consultation should look like this: SELECT * FROM `tabela` WHERE `data`…
-
2
votes2
answers524
viewsA: PHP routines, using Return
The usefulness of return is to 'transfer' a value from within a function out of it. A function returns some value for it to be manipulated in other parts of the program/script or works as a…
-
4
votes5
answers1088
viewsA: Digits in a java string
You can find out how many digits there are in the string and iterate it and compare the ascii code of each element, if it is in the range of 48 and 57 is a number. Example - ideone Wikipedia - ascii…
-
33
votes2
answers22203
viewsQ: What’s the difference between failure, defect and error?
In software development often problems occur in the application already ready, some terms used to classify them are: glitch, defect and error. What is the difference between one term and the other?…
-
1
votes1
answer130
viewsA: Using LIKE in Mysql
It is not possible. The clause WHERE is the condition that must be obeyed to return records within the established criteria. Your criterion was set here: I’m looking to search all registered…
-
8
votes2
answers6177
viewsA: How to insert index and element within an array
If you only need to create a new array, enter this in the assignment. As in the question at each foreach turn the value of $variavel is overwritten. To accumulate items in the array simply…
-
6
votes1
answer831
viewsA: Take the last exploding position
Use the function end() to leave the array pointer at the last position and get its value. $ultimo = end($geturl);
-
4
votes1
answer370
viewsA: SQL Server PDO error: There are no more Rows in the active result set. Since this result set is not scrollable, no more data may be retrieved
One way to resolve this is to inform the server that the query/command has ended and no synchronization type is required. Call the method closeCursor() after the execute() Your code should be:…
-
1
votes2
answers941
viewsA: how to get bank value in an if using php
The way the if is the comparison is made between an empty array and a boolean one that "true" is converted not because of the true in yes but because of the existence of some content. An interesting…
-
4
votes4
answers2570
viewsA: How to take the penultimate and antipenultímo item from an array
Another way to do this is to combine the functions end() which puts the array pointer in the last position and calls prev() which puts it in the previous position so this gives the penultimate…
-
10
votes5
answers1493
viewsA: How to create a function to validate time in PHP
It is possible to validate the format and contents only with regular expressions if you wish. ^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]). ^(0[0-9]|1[0-9]|2[0-3]) => The first group captures the time in…
-
3
votes1
answer930
viewsA: How does the White Box Test work?
White box tests evaluated the behavior of a feature. Whether a given input will produce the expected output or whether code has passed the desired stream. To perform this type of test you need…
-
10
votes2
answers14121
viewsA: SQL query for nonnull records only
Null is not a value, you need to use IS NULL to find null or void IS NOT NULL not null at the time of comparison. It should look something like: SELECT * FROM NotasFiscais WHERE NChave IS NOT NULL…
-
2
votes1
answer110
viewsA: How to resolve error message generated by Getsqlvaluestring function
WARNING: The functions mysql_* should not be used. The problem is that the function expects a scalar value but an array has been passed as argument, which gives the hint is the query string…
-
0
votes3
answers597
viewsA: Contar while php mysql
I believe that counting and grouping by the name of the supplier already solves the problem. SELECT count(*) as total, auxiliar_fornecedor FROM visualizacoes_telefone GROUP BY auxiliar_fornecedor…