Posts by rray • 66,288 points
1,220 posts
-
3
votes3
answers1297
viewsA: How to delete the last record from a table?
Unable to perform a DELETE with a subquery specifying the same table, as it says documentation. You cannot delete from a table and select from the same table in a subquery.…
-
1
votes3
answers107
viewsA: validation of superglobal
In programming, in part of time (ideally) you should not treat or change external elements within a function, that is to say function or method should not be able to be passed as argument or that…
-
1
votes3
answers93
viewsA: Error in declarations with Array
The syntax error of the code seems to be related to php version. This syntax is only available from php5.4 $ClientesRef->getNome()[0] To work around this, create a new variable and test it in if.…
-
4
votes3
answers465
viewsA: how to show the matrix in matrix form and not the numbers arranged on each other’s side?
Change the command write() for writeln() when writing the result. Change: write (iMat[iLin,iCol]); To: writeln (iMat[iLin,iCol]);…
-
4
votes1
answer107
viewsA: system with 2 databases , returning empty mysql php queries
As you are working with two banks it is mandatory to inform in which of them you want to perform the operation(Insert, update, delete select etc) otherwise PHP will get the last open connection. To…
-
8
votes3
answers7168
viewsA: Two conditions in the same if() javascript loop
Missed to take the value of each input and specify the operator that joins the expressions. In doing document.getElementById('email'); this takes the whole element, in your case you should only take…
-
8
votes1
answer55
viewsA: How do I change everything to a single php value
To set a value for all records of one or more columns only omit the WHERE no update. Some databases (like Mysql) have a 'lock' against an update/delete without WHERE because usually this is seen as…
-
8
votes2
answers844
viewsA: Omit seconds in Mysql time field
You can make time comparisons and presentations using the function date_format() Mysql to delete seconds. H represents the time in the 0-23 format and i minutes. Even if seconds are omitted from the…
-
4
votes2
answers83
views -
7
votes1
answer243
viewsA: PHP - Why should I put an IF in mysqli_prepare()
if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) { This if checks if the query does not have any syntax error or 'execution' as constraints violation, if I succeed does the…
-
6
votes1
answer638
viewsA: filter records by month
It is necessary to filter by month and year, take the field containing the date apply a month() which return the date month and year() that returns the year and makes the comparison with the desired…
-
2
votes1
answer82
viewsA: Validate text box so it has 9 numbers and can only start with 9 or 2
You can use a regular expression to do this, "988888888".match(/^(9|2)\d{8}$/); ^ sets which characters should be at the beginning of the line in this case 9 or 2 ((9|2) pipe acts as an OR/OR) that…
-
2
votes3
answers15821
viewsA: REGEX - find expressions that DO NOT contain specific words
If you need to do an exact search for a word to anchor(Boundary) \b and with the negative Lookahead(?!) to deny the group. regex for the example of the question: \bCOM\b\s(?!REV|LIB) The return is…
-
4
votes1
answer330
views -
2
votes2
answers100
viewsA: UPDATE giving error but updates database
Seems to have a logic error in the block below: //primeira ocorrência $sql = mysqli_query($conecta,"UPDATE agente SET login_on = '$date' WHERE login_ag = '$login' AND senha_ag = '$senha'");…
-
2
votes1
answer212
viewsA: How to get the generated Array from the print_r() function to send in the email?
To take the output/structure of some variable with the print_r() inform the second argument as true, thus the function returns the structure of the variable passed instead of printing on the screen.…
-
3
votes2
answers161
viewsA: How to insert the elements of the X array into an index of the Y array?
With PHP5.6 you can simplify this assignment by combining array_push() and the operator eclipse(...), it unpacks each element of the array as an argument to push_array(), in practice the generated…
-
4
votes4
answers94
viewsA: Table A data not contained in Table B
Can use a NOT IN() to know which users do not have cards associated: SELECT * FROM usuarios WHERE id NOT IN(SELECT IdUsuario FROM cartao) The query can be translated as, select all users where the…
-
14
votes5
answers64617
viewsA: Monetary mask with jquery.inputmask
If you are using the plugin jquery.inputmask, set the dynamic mask added the thousand and decimal separator options, to remove the underlines swap the placholder for zero. <html> <head>…
-
2
votes3
answers97
viewsA: Check the existence of the values of one array in the Keys of another
You can use the function array_intersect() to know what values the arrays have in common, array_flip() is used to invert the key/value pair. <?php $arr1[0] = [10,28,99]; $arr2[0] =…
-
11
votes1
answer4628
viewsA: What is the difference between Sanitize and filter in PHP?
The difference between FILTER_SANITIZE_* and FILTER_VALIDATE_*, is that the first tries to 'convert' an entry into a specific 'safe' format using well-specified rules. This modification does not…
-
13
votes2
answers3829
viewsA: Take AUTO_INCREMENT value from a table
Make an inquiry on information_schema it stores information about your database(metadata), the field to be returned is the AUTO_INCREMENT, it is necessary to inform the table and database. The code…
-
3
votes3
answers61
viewsA: Multiple entries in class attribute do not work
It is necessary to delimit where the values for the attribute begin and end class this is done as with the quotes can be the single or double, as in the echo is using the doubles, use the single…
-
2
votes1
answer45
viewsA: I am making a php form and I need to update the DB if a user makes changes to the data
To identify which elements of an array are empty, one way is to combine the functions array_keys(), array_filter(), array_flipper() and array_diff(). array_keys() obtains the keys(name, email etc)…
-
2
votes2
answers332
viewsA: Save Date in UTC Brazil Table
One way to resolve this globally is to define the appropriate Timezone(America_sao_paulo) in php.ini. Search or create this line in php.ini and restart apache after the change.…
-
1
votes1
answer7063
viewsA: Configure Mysql connection in eclipse
The first step is to lower the Jconnector on the Oracle website In the JEE eclipse, change the database perspective, usually this option is in the upper right corner. Right click on database…
-
2
votes1
answer1245
viewsA: Error mPDF library
To install the extension mb_string in centos rotate the following command line: yum install php-mbstring restart apache and see if it has been installed correctly, you can search the phpinfo() for…
-
2
votes1
answer28
viewsA: Method is not recognized within the class
In php a function is different from a method. Calling functions just calls the name. With methods it is necessary to say who owns it, outside the class is the object, inside the class is used the…
-
4
votes2
answers188
viewsA: Select with date returning empty
If comparing only the date, cast in both values to make the comparison 'to the correct extent'. The current comparison would be something like: WHERE '2016-06-26 12:00:01' = '2016-06-26 17:03:34',…
-
12
votes7
answers10590
viewsA: How do I know if today’s date is Saturday or Sunday (weekend) in PHP?
Another way to know this is by taking the day in full. As in English the Saturday (Saturday) and Sunday (Sunday) begin with the letter S, just know this. Behold: if (substr(date('D'), 0, 1) === 'S')…
-
7
votes1
answer3517
viewsA: Default error for datetime field in Mysql
Cannot set default value as now() or CURRENT_TIMESTAMP (which are synonyms) for datetime columns in versions prior to Mysql 5.6, in which case the simplest solution is to change the type of datetime…
-
1
votes1
answer596
viewsA: Result Search PDO PHP Does not return a field
Before extracting (fetchAll()) the results of the consultation shall be (execute()) she in the database. In your code add these lines. $sql = "SELECT Id, Nome, IdTransacao FROM dados WHERE id = 1";…
-
2
votes1
answer54
viewsA: Transactions does not work in structure creations/modifications?
In accordance with the documentation Mysql speaks, in general DDL(create, alter, drop, trucante) commands are not supported within transactions, as their execution causes a commit implicit or is…
-
3
votes1
answer73
viewsA: Questions on Check VB6 functions for PHP
The code takes a string 0202827610 is made a for that extracts a character from that string as mid() and has its value converted to double with Cdbl() which finally adds up the value. A way to…
-
7
votes2
answers471
viewsA: How to get the difference between dates and turn into hours?
Use the function timediff() he looks like datediff() but returns the time(hh:mm:ss) of two dates. To compare only the time, use function HOUR() thus only the time is returned, as in the third…
-
14
votes3
answers866
viewsA: What are "Magic Numbers"?
Magic numbers are numbers scattered in blocks of codes the two major problems are little semantics (information about use) and the possibility of this number being spread over N lines, which means N…
encoding-styleanswered rray 66,288 -
1
votes1
answer635
viewsA: Putting more than one SUBMIT input into an HTML form
Use the checkbox or select(yes/no) in the form to indicate whether or not the record should be saved to the database. As sending email is mandatory, divide the code into at least two functions one…
-
0
votes2
answers202
viewsA: Mysql query not returning
When using Mysqli remember that most functions the first argument is the connection and don’t forget the i in the end. The isset should be called before using any array key and not after the other…
-
2
votes1
answer124
viewsA: php - No update in Boolean field
b is for blob and non-Boolean fields/values, change the b for i if you are passing 0 or 1. Or switch to s for values t or f $stmt->bind_param("ssii", $name, $email, $active, $user_id);…
-
1
votes1
answer690
viewsA: A Database Error Occurred: You must use the "set" method to update an entry
One of the formats expected by the méotodo insert() is an associative array. In the current code call you pass the controller information($this) when the expected would be $banco. Change:…
-
0
votes2
answers63
viewsA: Error adding elements in Mysql Database with PDO
The code lacked specifying which Exception to capture, in the case of Pdoexception. Prefer to capture the more specific exception to know where the code failed and have the necessary details, while…
-
5
votes3
answers90
viewsA: strpos() is closing while true
The problem seems to happen in the second consultation due to the reuse of the variable $result in the second consultation change her name. To avoid false positives with the function strpos() use…
-
3
votes2
answers1508
viewsA: I cannot enter the values in the table with auto_increment in the primary key
In the auto-increment column you can omit it from the field list and the clasp VALUES or pass null as a value. Passing an empty string can work depending on the configuration of the…
-
3
votes2
answers63
viewsA: Moving from one function to another
Make this variable local, in a class member to do this just set it right after the class name. class usuario{ private $userFullname; //<--- definição do membro da classe public function…
-
4
votes1
answer35
viewsA: Filter a field according to the text format
You can filter numbers with like using the joker for a character _. SELECT * FROM tabela WHERE telefone like '(__)____-____' Related: What is the undescore "_" in the MYSQL LIKE?…
-
3
votes4
answers296
viewsA: Correct way to use php’s abs function
The two forms are correct, however one should use the bar before the name of the function or class when using namespaces this serves for all functions/classes of php core, from contario php will try…
-
4
votes2
answers501
viewsA: Undefined variable
In php variable names are case sensive or upper case are different from minuscules to global variable $_POST and not $_post and the most important detail, all requests by default use the get method,…
-
2
votes2
answers2008
viewsA: How to split an array and write to the PDO database
When using Prepared statemens put the tags(placeholders) in the query, do not pass the values directly in sql and remember column names, tables cannot be associated with placeholders only values.…
-
9
votes2
answers4065
viewsA: What are modules in programming?
Module is a Generic term to define a unit code or artifact with a specific purpose, the basic idea is to join certain elements by some criterion ex cohesion. Once grouped these elements can be…
-
0
votes1
answer78
viewsA: mysql_query() does not execute
In your code the problem is when the connection is successfully made $db_select receives true, enters the if and fatally falls in the die() and kills your script. The solution to this is to deny the…