Posts by rray • 66,288 points
1,220 posts
-
17
votes1
answer659
viewsA: What is the function of '@' (arroba) at the beginning of PHP expressions
@ error control operator at the beginning of function or variable call is to hide the error message. It is not indicated to do this because it masks the erro/warning and makes its detection more…
-
3
votes1
answer1439
viewsA: Codeigniter to know if Insert worked?
You can call the method affected_rows() which returns the number of lines affected by an INSERT/UPDATE/DELETE or check the return of query() is a Boolean $sql = "INSERT INTO usuario (nome, email)…
-
1
votes1
answer656
viewsA: How to access an array within a method in a class?
If the goal is a method to format an array, do not forget to give a return in the desired variable, a method/function without Return returns null, which in php is interpreted as false. Variables…
-
4
votes3
answers1561
viewsA: Increment letters in PHP?
As already mentioned, this is characteristic of weakly typed languages. this works because increment is done in the code ASCII(A-Z 65-90, a-z 97-122), and not exactly in the letter you see. This…
-
3
votes1
answer1187
views -
2
votes1
answer88
viewsA: Values of attributes of a duplicated object
I suggest you add simple quotes on all accesses of the database array and also assign values in the client object properties. Change the occurrences of: $auxCliente->$id = $consulta[CODIGO_CLI];…
-
6
votes1
answer671
viewsA: Run functions within variables in PHP
The error of in the second line because you try to call a string(return from abc()) as a function. If you are only calling the method you can use function call_user_func, being the first argument…
-
3
votes3
answers956
viewsA: Variable array assignment
Another way to convert an array for a string to use implode, the first argument is the array to be converted, the second would be delimiter that would be between the array items, in which case you…
-
2
votes1
answer821
viewsA: Update with JOIN in Mysql
The query has some syntax errors like aliases a and b a dot and comma left on the first line after the set, your query should look like this. UPDATE escrituras t1 INNER JOIN imovel t2 ON t2.LIVRO =…
-
2
votes1
answer610
views -
7
votes7
answers552
viewsA: What is the difference between these parameters (array) in these methods?
This first method defines $parameters must be an array if a value other than that is generated an error, if no argument is passed parameters will be treated as an empty array. public function…
-
4
votes3
answers619
views -
3
votes2
answers262
views -
0
votes2
answers236
viewsA: Error: Undefined index
It seems that your code is not expressing your idea is to display only one record, use WHERE clause no select. $stmt = $db->query("SELECT * FROM news WHERE id = '$newsid' ORDER BY id"); To avoid…
-
5
votes1
answer3433
viewsA: Slideshow with Mysql BLOB Images
You can display the image directly from the database(stream) in the tag <img> using the attribute srcthus: data:image/jpg;base64,stream_codificado.... In the.php view, make an array of all…
-
8
votes4
answers15217
viewsA: View PHP date and time
The problem is the function strftime, that does not make the timestamp conversion properly in windows, some arguments like alert documentation are not supported: %e, %T, %R, %D For your code to work…
-
7
votes3
answers579
viewsA: How to join data from another table
In your data table, you need to have city id and status. With these common fields do a JOIN, if the name of the fields are equal it is necessary to give an alias for each one or just put the correct…
-
14
votes3
answers18167
viewsA: PDO Drivers for SQL Server
Independent of doing a 'clean' installation or just updating some component (OS, PHP, Vcxx and MSSQL) it is highly recommended to check the SQL server driver compatibility with the other components…
-
2
votes1
answer400
viewsA: Line break interferes with regular expression capture
It seems that you are using php is what indicates the question link. In this case just add the modifier s in its regex, when using it with the dot metacharacter . new lines are combined/married.…
-
4
votes3
answers133
viewsA: Regex capturing it all
To capture only <span class='pages'>1 de 8</span> Add a query in regex, it means that the content group within the parentheses will match only once, it 'overrides' or combine everything…
-
1
votes3
answers736
views -
10
votes2
answers159
viewsA: "1-----1-+-1" is a valid integer value in PHP?
According to the documentation, this behavior is expected. In the case FILTER_SANITIZE_NUMBER_INT: Remove all characters except digits, plus and Minus Sign. Removes all characters except…
-
4
votes1
answer389
viewsA: How to change this PHP 5.3 code to PHP 5.4?
The error says that you are required to pass a variable(reference) to end function, it is not possible to pass the return of a function/method. To fix create an intermediary variable that takes the…
-
2
votes3
answers50069
viewsA: How to display all the results of a SELECT in PHP?
Add a while on mysql_fetch_* This way PHP evaluates whether the function returns true or false, if positive is assigned. To view 40 columns automatically create a for. $str = ''; while($linha =…
-
4
votes3
answers284
viewsA: Create folder and ID simultaneously using the same id number
To create the folder check first if the Insert did not fail. Do a check on execute(). Remember that the id is only returned after the Insert is successfully executed and the lastInsertedId() call is…
-
1
votes2
answers196
viewsA: Error Searching for Serial Postgresql
A suggestion to retrieve the inserted Quence id is to use the clause RETURNING in Insert, you also need to change Executenonquery() which returns the number of rows affected by Executescalar qu…
-
1
votes4
answers765
viewsA: How to put a DB column loop inside an array?
Based on the update and here, the only change is in place a numeric index define a key which is composed by the description of the database field which is represented by: $item['field']. <?php…
-
1
votes2
answers474
viewsA: Convert an entire number from the database into an Array
Range, generates an array based on a range, just enter the initial value and the limit, if you need a range other than 1 add the third parameter so the array value can be generated 2 in 2 or desired…
-
4
votes1
answer305
viewsA: Single user registration and password converting mysql_* to PDO
To avoid duplicate values set the column as direct Unique key by the bank. ALTER TABLE tabela ADD CONSTRAINT UNIQUE (campo) To convert code with PDO and Prepared statements $db = new…
-
4
votes4
answers6464
viewsA: Insertion of a dot every 5 characters
Another way to add a string based on an interval(5 characters) is to use the function wordwrap. The third parameter is the character to be inserted and the fourth forces php to add the character in…
-
6
votes1
answer4812
viewsA: Comma calculation in PHP
The decimal separator is .(point) and not ,(), to solve this you can use str_replace to exchange comma occurrences for points. No sum is performed :P seems that the plus sign has been exchanged for…
-
18
votes4
answers7268
viewsA: Get a Youtube video ID from the URL
Can use parse_url to extract fragments from a url and match parse_str that converts a valid querystring into an associative array ($param). <?php $url =…
-
2
votes3
answers780
viewsA: JSON data capture with PHP
Use the function json_decode and pass true in the second argument to turn the return into an associative array. Then call the key you want. $arr = json_decode($json, true); echo…
-
2
votes2
answers872
viewsA: I need help creating two tables with PHP decision structure
The first step is to get the word size with the function mb_strlen, done this check whether the word size returns or not the rest of the division($tamanho % 2 == 0). Now define an array with the…
-
1
votes4
answers1914
viewsA: Take accent from a string
It is also possible to do this with str_replace, the first argument uses an array with accented characters and the second with the characters to be replaced. $acentos = array('À',…
-
3
votes2
answers736
viewsA: PDO::rowCount() returning -1
This is the problem when a select is sent is not guaranteed that all databases return the number of rows (it returns the number of rows affected by a DML: DELETE, INSERT, or UPDATE), the proper…
-
3
votes2
answers166
viewsA: Insert the last table data into a second table
If the ids have the same value in both tables ex id 1 - café. Can make the difference of product table 1 by product 2 and use result as Insert at once. Insert into produto2(id, descricao) select id,…
-
6
votes3
answers641
viewsA: How to connect to Mysql only once, without having to instantiate every time?
The ideal would be to break this code in two classes one only for the connection of the bank (if it changes the change would be only in one place) and another for the site, in the latter the builder…
-
1
votes1
answer77
viewsA: "You have an error in your SQL sintax"
The error says that your sql query is not well formatted, it probably only happens the first time the page is accessed. Because $_GET['id'] doesn’t exist on the first call. Add a if and check…
-
3
votes2
answers5645
viewsA: How to compare all positions of an array in PHP
Place a foreach after the while to make the comparison of each line that comes with the bank for each value of $arrayDiasSemestre. while ($arrayDisp = mysql_fetch_array($oProfessor->retorno())){…
-
1
votes2
answers2050
viewsA: Download spreadsheet using the Phpexcel class
To force the download of an excel sheet it is necessary to define the header, stating how the content should be treated by the browser and invoke the method save() of some Writer //definição do…
-
3
votes1
answer287
viewsA: How to turn a string into a select with PHP?
Use explode to transform the string into an array, it is necessary to pass a delimiter which in this case is ,(comma). If the value of the description is the same as value, just put the value of the…
-
1
votes1
answer1827
views -
1
votes1
answer172
viewsA: Error in row mysql_fetch_array
It seems to be just a typo, your connection object is $mysqlli and at the time of calling the method query() you call a variable that does not exist $mysqli. To correct change the call from: $query…
-
1
votes2
answers186
viewsA: How to make the id variable not repeat in the loop?
This message appears when the query, when the number of columns is different from the number of values or is more and less columns or otherwise, in your code the way that requires less changes is to…
-
8
votes3
answers3171
viewsA: Read txt file for Select
For few records you can use the function file(), it loads the entire file and convert the lines of the array. <?php $linhas = file('teste.txt'); ?> <select name=select > <?php…
-
8
votes3
answers245
viewsA: Programmer of Windows Tasks
If you need to run a php script automatically, call it from the line instead of invoking IE with the page/script you want, so you don’t worry about closing the browser when processing the window cmd…
-
4
votes5
answers26088
viewsA: Registration problem (Column Count doesn’t match value Count at Row 1)
The error says that the number of columns is different from the number of values passed in the clause VALUES. The way the code is there are 7 columns and only one value, because only a single quote…
-
3
votes2
answers4410
viewsA: run script with admin permission
Create a function that prompts the user, password and returns a credential object: function getCredencial(){ $usario = Read-Host "Usuario" $senha = Read-Host -AsSecureString "Senha" return…
-
3
votes3
answers1429
viewsA: Generate sequential number within one month
You can extract the number of the last service order and generate a new one, making a query that returns the largest number of that month and add one more, if the query does not return nothing means…