Posts by Wallace Magalhães • 1,242 points
52 posts
-
7
votes2
answers969
viewsQ: What is the usefulness of the service layer in the Laravel?
What is the real usefulness of a service layer in the structure of Laravel? It’s just about separating the code from the Controller? How to use this layer correctly? My biggest question is whether…
-
12
votes2
answers188
viewsQ: Is there a difference in performance between "new" and "clone" in PHP?
What is the advantage of using the clone instead of the new to create an object in PHP? I know that to use the clone it is necessary to pass an instantiated object. But because it is not necessary…
-
4
votes2
answers106
viewsA: When or how to integrate php code into html
You are not wrong and you are not right. There are cases and cases. I don’t particularly like using PHP to render HTML. In my real scenarios this made it difficult for me to maintain and I lost a…
-
5
votes2
answers3690
viewsQ: Regex to capture words between two characters
My problem is this: let texto = "teste :1: e também teste :2:" What I need to do is basically take the positions where these characters appear :1: and :2: with regex, since what appears between the…
-
1
votes3
answers58
viewsA: How to concatenate a variable in the middle of another variable?
In your example it doesn’t work because PHP is looking for the variable $name_list, that doesn’t exist. To get the effect you want, I think it would be this way. $varName =…
phpanswered Wallace Magalhães 1,242 -
2
votes2
answers3047
viewsQ: How to insert HTML within an Angular 4 Component?
Hello! How to insert an HTML code into an Angular Component? For example: I have the Component button: whose code is: <button type="submit"></button> I would like to insert the html in…
angularasked Wallace Magalhães 1,242 -
2
votes1
answer297
viewsQ: What’s wrong with this Delphi code?
On the mainform onCreate, I have the following code: procedure TForm1.FormCreate(Sender: TObject); begin QuickRep1.Prepare; QuickRep1.Printer.Load('arquivo.qrp');…
-
0
votes1
answer138
viewsA: POST method not working on the same page
Place the attribute enctype="multipart/form-data" in the form tag, it is necessary when there is file upload. <form enctype="multipart/form-data" method="POST">…
-
3
votes1
answer2600
viewsA: how to close a popup with javascript
with this code you can close: <a href='#' onclick='window.close()'>Fechar modal</a>
-
2
votes1
answer590
viewsQ: Is it possible to read a Quick Report file (qrp) from PHP?
Hello, I have a Quick Report file (format .qrp). I need to analyze its data from within PHP, but I was not successful. Is there any way to do that?
-
2
votes1
answer86
viewsQ: How to give permissions to all Mysql users at once?
I have a database that all Mysql users should be able to access. I’ve tried a GRANT ALL PRIVILEGES on nomedobanco.* to '%'@'%' identified by, but without success. How can I do that?…
mysqlasked Wallace Magalhães 1,242 -
2
votes1
answer337
viewsQ: What is the function of the __wakeup magic method in php?
I read the documentation, but it wasn’t very clear. __wakeup() reestablishes connection to the database? For example, I have a script that runs for quite a while, there comes a time when the…
-
3
votes3
answers1024
viewsA: Take comma-separated values from the database and organize them into <li>
Yes! Function explode(). Example: $lista = "item1,item2,item3"; $lista = explode(",", $lista); // Aqui lista passou a ser um array("item1", "item2", "item3"); To write the Lis, just use the…
-
4
votes1
answer1223
viewsQ: Is it possible to run a different PHP in a given folder?
I got a problem: The server uses PHP 5.3, which is very old but cannot be changed. I have a script that requires PHP 5.4+, websocket Ratchet. It is possible to install a separate PHP to be used only…
-
4
votes1
answer1212
viewsA: Problem trying to list error -> "Trying to get Property of non-object in"
Your listar_servico() method does not return an object, but an array. But there is one detail: when you give a $rs Return there inside the while, you are at the same time interrupting the loop. This…
phpanswered Wallace Magalhães 1,242 -
2
votes1
answer107
viewsQ: Rollback method does not work in mysqli extended class
Hello, Because of the PHP version on the server, the fetch all and begin_transaction methods of mysqli do not work. To solve this, I created another connection class extending the Mysqli class and…
-
2
votes2
answers47
viewsA: Problem with sending email with php
Add the following line to the $headers: $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
-
0
votes0
answers207
viewsQ: Send a message to the client when there is a system change with Websocket Ratchet PHP?
Hi, I made a PHP Websocket with Ratchet. The server.php is as follows: require "../vendor/autoload.php"; use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; use…
-
2
votes1
answer94
viewsQ: Is there a difference between saving settings to dotEnv, JSON or INI?
To save sensitive application data, it is recommended to save in dotEnv or I can save in any other format where the file is not in the public directory? I see many talking about dotEnv, I wanted to…
-
1
votes2
answers97
viewsA: Error with select in mysql
Means your query is not running correctly. Place these lines before fetch_array() to find out what the error is: if (!$result) die ($mysqli->error);
-
-1
votes2
answers76
viewsA: Problem with bank call for listing
You are mixing the procedural mysqli with the object oriented mysqli. The following is the correct one: $selecionar = "SELECT id, horas de segunda feira FROM horas_segunda"; $dados =…
-
1
votes1
answer336
viewsA: Error returning from get from Delphi to php
Try saving the answer in a Stringstream. procedure TForm2.Button1Click(Sender: TObject); var Urls : string; lResponse : TStringStream; begin lResponse := TStringStream.Create(''); try urls :=…
-
1
votes4
answers5322
viewsA: Send Javascript array via Ajax with jQuery for PHP file
Just add [] after the variable name. Example:…
javascriptanswered Wallace Magalhães 1,242 -
0
votes1
answer48
viewsQ: Can I use a function in the declaration of an attribute in PHP?
Hello. You can do something like: class Net { public static $ip = getenv("REMOTE_ADDR"); } Take the return of a function and assign directly in the property? Or create a variable outside the class…
-
1
votes2
answers60
viewsA: Session without www and www php
Specify a directory where both can save the session. To do this, use session_save_path(). Take a look at the documentation, the syntax would look something like this: <?php…
-
1
votes1
answer166
viewsA: Problem with return of PHP’s Mysqli class fetch_all method
I got it this way: <?php class MySQLiConnector extends \mysqli { function __construct($host, $user, $pass, $db) { parent::__construct($host, $user, $pass, $db); } public function query($query) {…
-
1
votes1
answer166
viewsQ: Problem with return of PHP’s Mysqli class fetch_all method
So, I’m doing the maintenance of a very large system. I have the query: $query = $mysqli->query("SELECT*FROM tabela"); And the problem is they used fetch_all() to return the data. When the query…
-
1
votes1
answer124
viewsA: Problems accessing PHP page via Ajax
This information in the access log says that the request returned status 200 (Ok). It is not an error. The problem, as Ivan said, is that with $.ajax() you should not use $.parseJSON(). You need to…
-
12
votes6
answers1348
viewsQ: Is there an alternative to system('cls') in PHP Console?
I’m using PHP (5.7) on the console (Windows 10), but I’m not able to clear the screen. I give a system('cls') and only a little square with a question mark appears, without cleaning the screen. I’ve…
-
6
votes3
answers380
viewsA: Use variables outside the function
This was already possible in older versions. You can use the scope global. Example: $msg = "Olá!"; function exibeMsg() { global $msg; echo $msg; } exibeMsg(); // Imprimirá "Olá!" You can access the…
phpanswered Wallace Magalhães 1,242 -
2
votes1
answer344
viewsQ: Is it possible to list the columns used in a SELECT in PHP mysqli?
I have the query SELECT coluna1, coluna2... FROM tabela I wonder if there’s any method in the class mysqli to return these columns that were used in the query, even if the query does not return…
-
0
votes2
answers161
viewsA: Popular PHP dropdown error with array
use foreach to traverse the array: <?php $redesBanco = listaRedes($conexão); ?> <div class="form-group"> <select class="form-control" id="dropdown-parceria"> <option…
-
6
votes2
answers221
viewsQ: Use of methods in php object orientation
Hello, I have the following question: In this example: class produtos { public categorias = []; } categories is a vector, as you can see. Its structure is as follows:: $categorias["tvs"][0] = "aqui…
-
7
votes1
answer147
viewsQ: Is there a magic method for calling an attribute as a method in php?
For example, we have the class: class foo { var $bar = 1; } I was wondering if you could run something if I called it that: $foo = new foo; $foo->bar();…
phpasked Wallace Magalhães 1,242 -
0
votes2
answers732
viewsQ: How to track Curl PHP redirect?
Use the curl to capture data from a page, but is returning the code 301 (moved). I used CURLOPT_FOLLOWLOCATION, but it’s still the same. Someone knows how to track redirect?…
phpasked Wallace Magalhães 1,242 -
0
votes2
answers505
viewsA: Calling protected variable inside static method
Unable to access class attributes or other methods within a static method. Static methods are not in the context of the object.
-
0
votes1
answer121
viewsQ: How to avoid the ajaxStop() method function in a single ajax call?
I have the following problem: There is a page where I use $.ajaxStop to give a $.unblockUI (modal plugin), this closes the modal "loading..." whenever the page ajax requests finish loading, the…
-
2
votes1
answer97
viewsQ: Webserivce only accepts requests from local server
I have a Webservice in PHP and need to use to integrate two applications. WS returns in JSON the data I need. The problem is that it returns only the data when the request is made from a local…
-
0
votes2
answers119
viewsQ: I converted a two-dimensional array to an object in PHP. How to access the values?
Hello, I have the following matrix: $array[0]["nome"] = "nome exemplo"; $array[0]["idade"] = "idade exemplo"; $array[1]["nome"] = "nome exemplo 2"; $array[0]["idade"] = "idade exemplo 2"; I created…
-
3
votes2
answers2958
viewsQ: How to find the origin of the request in PHP?
Hello, I have a PHP page that receives ajax requests from another page, in another hosting, this was possible using header('Access-Control-Allow-Origin: *'); So far so good, but I’d like to know…
-
-1
votes2
answers102
viewsA: Error trying to submit form with AJAX file
Parameter is method, not type: $.ajax( { url: "recebe.php", method: "POST", data: formData, success: function(result) { alert(result); } });…
-
-3
votes3
answers945
viewsA: Problem with php query because of quotation marks
use the addslashes function(). Example: $query=addslashes("INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal','Tom B. Erichsen','Skagen…
-
0
votes5
answers32695
viewsA: Read and manipulate json data using jquery
$.get is a simplified version of $.ajax, has fewer parameters. To use json one must use ajax, since it has the datatype parameter, which must be set to json. in this case: $.ajax({ method:"get",…
-
5
votes2
answers7863
viewsA: When should I use GET function and when should I use POST function?
You already know how each one works, so I’ll give examples of when to use. GET passes variables by URL, it is useful for you to share a product page, make pagination, such things... That is, as a…
-
2
votes2
answers168
viewsQ: Inclusion of external files . js
Guys, I have a . js file in meudominio.com/.js file (example). This file contains functions that send requests via Ajax to another file, the.php data (does the search and returns in json), which is…
-
2
votes2
answers62
viewsQ: How to include a js from another domain in html?
Hello, I have a file . js on http://meudominio.com/arquivo.js. I would like to call you elsewhere (meudominio2.com) with <script src="meudominio.com/arquivo.js" ></script>, however,…
-
1
votes1
answer81
viewsQ: JSON return giving as undefinided in jQuery
I have this ajax request: $.ajax({ type: "POST", url: "retorno.php", success: function(data){ alert(data["nome"]); }, error: function(erro){ alert(erro); } }) And the return.php file: <?php…
-
1
votes2
answers972
viewsQ: How to change the data type in $.post request in jQuery?
var envio = $.post("processamento/busca.php", { unidade: $("#unidade").val() }) I have this request, I would like to change the datatype to json, in ajax you have a datatype parameter, but I don’t…
-
0
votes2
answers964
viewsA: How to send an email after a new mysql registration
The above friend already explained basically everything. And if you are wondering how to send the email, you can use this class I created: <?php class Email{ var $remetente_nome; var…
-
0
votes3
answers1345
viewsA: It is possible to configure upload_max_filesize via . htaccess
You can use the function ini_set() in PHP! Just put the contents of the . ini line as parameter: <?php ini_set("upload_max_filesize", "10000"); Doc: http://php.net/manual/en/function.ini-set.php…
phpanswered Wallace Magalhães 1,242