Posts by rray • 66,288 points
1,220 posts
-
1
votes1
answer96
viewsA: Problems search php Pdo
Missing argument 1 for Command::__Construct() Failed to pass argument(variable or value) in constructor Comando, probably here: $objComando = new Comando(); //<---- cadê o argumento que é a…
-
0
votes1
answer401
viewsA: Display only landline and mobile phones with type 9 in front
You can use the functions replace() and char_length() Mysql to subuse the blank space for nothing and count the number of characters in your phone and check if it has 11 digits in the WHERE thus:…
-
3
votes4
answers158
viewsA: Passing argument by PHP array
The problem is called from the function, need necessarily 3 arguments, to pass they can turn this string into an array with explode() and spend each one individually. $a = array("1,2,2016",…
-
1
votes3
answers201
viewsA: Is making queries in a view, in the MVC standard, a bad practice?
The idea of the MVC standard is to separate the concepts, in the case of the web the code that has some functionality (controller and model) and view that is usually a file with code of little or no…
-
1
votes1
answer604
viewsA: failed to work with base_url in Codeigniter 2.2.6
You can configure the project url by setting a value for $config['base_url'] this variable is in the config.php file in the config folder. $config['base_url'] = '/ci/';…
-
1
votes3
answers2173
viewsA: How to select all tables in mysql
You can do this in Mysql, through information_schema that stores database metadata. SELECT * FROM information_schema.tables WHERE table_schema = 'database'…
-
1
votes2
answers619
viewsA: Pass array to Modal
The echo serves to print scaler values(int, string float etc) except arrays and objects. You can take the array and turn it into a json string with php and by javascript convert to an object.…
-
1
votes3
answers2863
viewsA: Copy data from one table to another without entering field by field
In SQL Server and other databases you can use select into (with some syntax differences) SELECT * INTO nova_tabela FROM outra_tabela Inserting Rows by Using SELECT INTO…
-
4
votes2
answers956
viewsA: PDF Decode Base64
I believe it is better to create a new php file, to generate the pdf, basically its content is a query to the desired record, correct header formatting for the browser enteder that this output(plain…
-
2
votes1
answer365
viewsA: Format SQL read variable hours and minutes presentation
You can use the function date() with strtotime() to format the time correctly, it is also possible to do this directly by sql. PHP echo date('H:i:s', strtotime($row["horas_assis"])); SQL SELECT…
-
2
votes1
answer69
viewsA: Manipulation of JSON
You can solve this by creating an Indice variable to group the label and value. $Json = array(); $i = 0; foreach ($Dados as $ln){ $Json[$i]['label'] = $ln['NOME']; $Json[$i]['value'] = $ln['EMAIL'];…
-
5
votes3
answers5416
viewsA: Phpdoc - What is, what is its utility and how to use it?
Phpdoc is a way to add information about a structure (méotodo or class etc) they are useful for some tools that automatically generate documentation from these 'comments'. This information is…
-
0
votes1
answer185
viewsA: List multiple MYSQL records in PHP email to send them all at once
It is only sent the last record because every turn in the while $mensagemHTML has its value rewritten. To solve this set the variable before while and concatenate the string with .= change:…
-
1
votes1
answer1510
viewsA: Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[42000]'
day(), month() and year() are functions to extract specific pieces of a date and your call on the Insert is 'reversed' instead of data_agenda(day) sure would be day(data_agenda), but you save 3…
-
1
votes2
answers87
viewsA: Mysql PDO array with Json error in view
In your javascript the first step is parsing the string sent by php in a valid json, then you can access the array like this: lista[i].user_name or lista[i]['user_name'] or you can still use jquery…
-
0
votes2
answers66
viewsA: The second Store Procedure QUERY does not run... I did not find the bug
Commands out of Sync; you can’t run this command now This error usually happens when using stored procedures with the functions mysql_*, the message says something like "I can’t process that query…
-
4
votes1
answer10272
viewsA: How to fix "1452 > a Foreign key Constraint fails" error using PDO in PHP?
The error happens because you try to insert a value that does not exist in the client table, because by adding simple quotes the placeholder(query) becomes a literal. Change: INSERT INTO pedido…
-
25
votes6
answers2300
viewsA: AJAX is not a programming language. So what is it?
AJAX(Asynchronous Javascript and XML) is a technique that uses javascript to send asynchronous requests to a server, making pages and web systems (of the time and today) more interactive. The term…
-
3
votes1
answer1227
viewsA: Mysqli Cannot pass Parameter 2 by Ference
bind_param() does not accept values as second argument, only references or variables, make the assignment of values in it and solved problem. The error generated is: Fatal error: Cannot pass…
-
3
votes2
answers3194
viewsA: Call to a Member Function fetch_assoc() on a non-object
Call to a Member Function fetch_assoc() When you come across the above error, it means that your query failed, to know the origin of the error check the previous line to call fetch_assoc() that is…
-
10
votes4
answers10456
viewsA: Workbench for Postgresql
There are some options of graphical managers: Free: Phppgadmin Pgadmin Paid: Postgres Enterprise Manager Here is a list of other tools.…
postgresqlanswered rray 66,288 -
2
votes2
answers66
viewsA: Numberformatter does not work MIN_FRACTION_DIGITS, 2
Change MIN_FRACTION_DIGITS for MAX_FRACTION_DIGITS to define the maximum number of digits of a fraction, in case 2. <?php $valores = '54.98054562'; $moeda1 = new NumberFormatter('pt_BR',…
-
7
votes4
answers1047
viewsA: How to invert words and count total characters
If Encode (ISO-8859-1) is configured correctly the functions strlen() and strrev() work as expected, if using UTF-8 prefer the approach below. stlen() Does not count the number of characters but the…
-
2
votes3
answers4076
views -
3
votes2
answers421
viewsA: What is TDD and what is it for?
TDD stands for Test Driven Development, is a methodology in which test codes are written first even before there is any 'production code' that includes the definition of a class or method. Over the…
-
8
votes2
answers1310
viewsA: How to remove a word from a string without changing larger words that contain it
I don’t know about R, but a little regex, in this specific case you can use the exact anchor(\b) to marry exactly the word bem stringr::str_replace_all(s, "\\bbem\\b", " ") Related: What good is a b…
-
2
votes1
answer1773
viewsA: Handle Mysql error
When an Insert failure occurs you can send the user a generic message, when the failure is for a duplicated item (1062), take the specific sqlstate(error code) and compare within an if. mysqli_errno…
-
1
votes1
answer42
viewsA: Login page using mysqli_fetch_row
Use Prepared statements to avoid sql injections and do not store passwords as plain text. When using pass the values directly in the query the string values(varchar and others of type text) need…
-
3
votes2
answers1198
viewsA: Check for capitalized words
To find out if there are upper case letters in a string you can use a simple regex [A-Z] with the function preg_match(). <?php $entradas = ['Um', 'min abc', 'aÇão', 'ação', 'CAPS'];…
-
1
votes1
answer1005
viewsA: Running 2 queries at once is possible?
This behavior is expected, the second query overwrites the value of $stmt, you can solve this in two ways, create two Prepared statemetns or call twice the excute() respectively after the prepare()…
-
5
votes1
answer1718
viewsA: How does auto increment work with composite keys in the Myisam engine?
Solution (if you really need a composite PK with AI field) The 'problem' is restricted to the Myisam engine, as Innodb does not allow this type of construction. This repetition happens only when the…
-
5
votes1
answer1718
viewsQ: How does auto increment work with composite keys in the Myisam engine?
I ended up taking a table to manipulate, I noticed that sometimes the value of auto increment repeated, the first thing that called me the attention was that the key Primary was composed of two…
-
1
votes1
answer27
viewsA: number of variables does not match the mysqli parameters
In your query there is no placeholder, values should not be passed directly but exchanged for only questions(?) it is not necessary to use simple quotes to escape them when using Prepared…
-
3
votes1
answer73
viewsA: Accessing data from an array
Has the Intel zero before id and the others, the right is $vetor[0]['produto']. One way to see organized array or object structure is to use this code echo '<pre>'; print_r($arr); Thus it is…
-
2
votes1
answer110
viewsA: How to check if something has been passed to the php page?
Have two options, check if there is something and execute the desired code or throw this code block in the default case(default) switch. The difference between the two is, the first executes or…
-
6
votes3
answers872
viewsA: Split into two parts when it contains more delimiter in string with explode
You can use the function strstr() to return what is right of the string: echo strstr('Leite Pasteurizado, Mucuri, Integral, 1 L', ' '); Returns: Pasteurizado, Mucuri, Integral, 1 L…
-
1
votes1
answer41
viewsA: Error when including file within function
The problem is that include is done inside the function, so all variables defined in it and include’s are restricted to function as nothing is returned occurs undefined variable. Do it right, in…
-
0
votes2
answers286
viewsA: Validation of javascript fields?
With pure javascript create a function and call it on onsubmit() as argument is passed the form with all its fields, then it is possible to validate them in this way form.campo.value <html>…
javascriptanswered rray 66,288 -
7
votes3
answers210
viewsA: Function contrary to TRIM
Mysql has the function concat() to concatenate strings as it can receive N arguments you can put anything at the beginning and at the end. update tabela set campo = concat('inicio ', campo, ' fim')…
-
16
votes4
answers1512
viewsA: What is reverse engineering?
Reverse engineering is the opposite process of the usual software development or not, from something already generated get access or discover how something was done without having the internal…
-
19
votes14
answers126839
viewsA: Phone Mask Using jQuery Mask Plugin
Another option to apply a mask on phones with 8 or 9 digits dynamically is to use the plugin jquery.inputmask. Two masks are set one for eight digits and one for nine, the person responsible for…
-
2
votes2
answers111
viewsA: INSERT duplicate with mysql ::PDO
When calling the method execute() of PDO it executes the query contained in that Prepared statement, in your code you have two calls. Remove the first occurrence $lc_follow_dados->execute();…
-
0
votes1
answer94
viewsA: Problems deleting data from table with ::PDO
When using Prepared statements it is not necessary to escape the values with simple quotes: DELETE FROM `lc_follow` WHERE `f_de`=':f_de' AND `f_para`=':f_para' ----------------------------------^ ^…
-
9
votes2
answers2552
viewsA: Which IDE supports PHP 7?
Some of the novelties of PHP7 Anonymous classes. Return type declaration. Operator null coalesces (??) Spaceshipe operator (<=>) The Phpstorm 10 has the syntax of PHP7 is a paid IDE. A…
-
8
votes1
answer139
viewsA: How does the data capture of a form work?
Request is for sending requests to the server. Response is the server response to the client. A web application or system works totally different from a desktop or console where all processing takes…
-
3
votes2
answers7460
viewsA: How to list table-specific data with PDO?
Simple consultation To make a simple query with fixed parameters or without them can use the method query() he does exactly the same thing as the mysqli_query() i.e., it processes a query and…
-
2
votes2
answers955
viewsA: Paint table row when receiving specific data
Add an if na <tr> which checks if the state is SP if yes, add the class you want to paint the line, do not do anything. <tr class="<?php if($objProg->getdest() == 'SP') echo…
-
3
votes1
answer530
viewsA: Infinite loop, object orientation
The infinite loop happens because at each turn of the while the same result is returned the resultset does not advance or the first row of the table is returned N times and will never return false…
-
2
votes1
answer1299
viewsA: Uncaught Exception 'Exception' PHP
This message is displayed on the screen because your Exception has not been handled, so a fatal error will be triggered to warn you as the documentation explains. If an Exception is not Caught, a…
-
1
votes2
answers1495
viewsA: Cannot use Object of type Pdostatement as array
Cannot use Object of type Pdostatement as array in The error suggests that the return of select is not an array but probably an object, so change the notation of: header('Location: ' .…