Posts by 13dev • 2,415 points
133 posts
-
0
votes1
answer369
viewsA: do not import blank lines - php
Adds this condition to $linhas = fgets($lines);, with this condition will ignore blank lines. Chooses one of the two conditions both result, in my opinion I prefer the first. if ($linha[0] == "\n")…
-
3
votes2
answers472
viewsA: Reading data from a Json with php
Your key pedidos is an array, so I understand it will only contain 1 element so it only accesses 1 element $jsonObj->pedidos[0]->feito_data;
-
0
votes1
answer567
viewsA: Ajax and PHP Update
To be honest your code is bad, vulnerable to sql Injection, without checking the indices of POST using Closest. First of all I would advise you to use PDO or MYSQLI. Try to save your data to an…
-
1
votes1
answer53
viewsA: Create numbered files in order
After seeing so much negativity in the other 2 comments (including mine) I decided to make a recursive function for this question. This function can have 2 or 3 different uses and I think one of…
-
1
votes1
answer33
viewsA: Populating Var Colors with database data
Your problem is that you’re making a loop where you’re always declaring the same variable, which means you only have one value. Try it this way: PHP $colors = []; while ($result =…
-
2
votes2
answers463
viewsA: How to open external urls with php functions
That mistake happens because you have an extension deactivated in php configuration Open your file php.ini search for this line and remove the ; front of this extension, example:…
-
2
votes2
answers865
viewsA: Error when receiving php array in ajax
Here’s the code with some changes and better habits for your programming. To be direct your code is bad, here is the possible solution that would use the function isset(): Pay attention to the…
-
3
votes2
answers532
viewsA: Change the execution of the onchange function from the select tag to an onclick function on a button
You can do the following example: <input type="text" id="convert" placeholder="Insira os segundos"> <br> <button id="converter">Converter</button> <select…
javascriptanswered 13dev 2,415 -
0
votes1
answer388
viewsA: Filter email by subject with PHP script
Try to use imap_fetch_overview() i think this way is easier than using imap_header, example: // usei o ciclo for porque é mais conveniente nesta situação // tem cuidado com $i = 1, verifica se…
-
1
votes2
answers1787
viewsA: How to convert a string into an object in Javascript?
The best solution would be jQuery.parseJSON Documentation var obj = jQuery.parseJSON('[{ label: "Agostinho", value: "1" }]'); example how you could use in the function montaAutocomplete: function…
-
1
votes2
answers503
viewsA: Passing $_FILES in a registration function
There are a few things I wouldn’t advise in your role like using @ to cover up, pass the connection and query by parameter, use strstr function, advised an array to check extensions, here is an…
-
1
votes1
answer156
viewsA: Redirect to specific folder as soon as user accesses domain
just use the native php function header() example: header('Location: www.site.com/novocaminho'); or if you prefer to use . htaccess, metes in the root directory example: Redirect 301 /…
-
1
votes1
answer640
viewsA: Jquery create object containing form data
You can create an array with an example key and associated value: var pesquisaArray = { id: $('input[name="id"]:checked').val(), // pegar valor de um radiobox id_usuario: 200, id_pesquisa:…
-
0
votes1
answer35
viewsA: GD/PHP Add text from form / Transparent Background
here’s an example: <form action="proccessImage.php" method="post"> Input: <input type="text" name="input1"><br> <input type="submit"> </form> When you click on the…
-
0
votes2
answers101
viewsA: Select with checkbox
use ajax! example: $.post("insertCidades.php", { cidades: colors }, function(result){ $("#resultado").html(result); // imprimir o resultado }); in the archive insertCidades.php $cidadesArray =…
-
1
votes2
answers135
viewsA: Using Templates with PHP
you can use a variable! //tens de declarar antes de chamar o arquivo content $script = '<script type="text/javascript" src="source.js"></script>'; In the archive php content. [..] echo…
-
0
votes3
answers29
viewsA: Check if the product id exists in the simulator id_product
Hello, use Prepared Statements, so your code won’t be vulnerable to sql Injection example with your code: $sql_simulador = $conn->prepare("SELECT * FROM simulador WHERE id_produto = ? ORDER BY…
-
1
votes1
answer670
viewsA: how to send an array list to a web service
I’ll give you a small example: <?php $test_array = array ( '_foo' => 'bar', 'foo' => 'bar', 'outro_array' => array ( 'pt' => 'stackoverflow', ), ); $xml = new…
-
0
votes1
answer67
viewsA: Return getJSON
To check if the json is empty, try the following if (!$.trim(json)){ alert("a variavel json esta em branco " + json); } else{ alert("a variavel json não esta em branco: " + json); }…
-
1
votes3
answers1803
views -
1
votes1
answer611
viewsA: Retrieve dynamic checkbox value in php
Summing up by what I understand you want to get the checkbox value that the user chose ? I’ll give you an example: HTML <form id="form" class="form" method="post" name="meuform"> <textarea…
-
2
votes1
answer166
viewsA: How to initiate a method when the user presses the delete or Return (delete) key?
Hello try adding the directive to your input: ng-keydown="teclaPress($evento)" and in your controller adds the function keyboard $scope.teclaPress = function(ObjKey) { // teu codigo por exemplo…
-
11
votes2
answers12319
viewsA: Format date and time with PHP
I would suggest you use this method will be much simpler you can do it this way (new DateTime($datamensagem))->format('d/m/Y H:i:s');…
-
0
votes1
answer82
viewsA: Problem creating SQL INJECTION security
I suggest you read more about PDO Try to change this $upd_sintaxe.= $upd_campos[$upd_aux].":".$upd_campos[$upd_aux].", "; for $upd_sintaxe.= $upd_campos[$upd_aux]."= :".$upd_campos[$upd_aux].", ";…
-
0
votes1
answer27
viewsA: I cannot select the dynamically created radiobuttons
Changes this line to: $('#addr'+i).html("#'"+(i+1)+"' <div class='row'><div class='input-field col s7'><input type='text' name='item_pergunta["+i+"]' id='item_pergunta'><label…
-
0
votes1
answer53
viewsA: Delete button does not work
Sending two POST’S Tries to remove the POST done by form On the delete button changes the type of Submit to button and assigns an id Follow this example from w3schools In my case I use the Postman,…
-
0
votes1
answer80
viewsA: Explode php string
Or you can do the following: <?php $json = str_replace('\n', '', $json); ?> is an option when you have n between text
-
0
votes2
answers3254
viewsA: Angular.js, is it MVC, MVVM or MVP?
Angular js is based MVW The MVW standard is not really a standard, MVW, it means Model-View-Whatever, IE, whatever standard you think will program in Angularjs, do not waste time, just do. Source...…
-
0
votes4
answers1027
viewsA: How to set a value in an input tag of another site?
You can use the GET example method: $x = $_GET['id'] ? $_GET['id'] : NULL; and in html: <input type="text" value="<?= $x ?>"/> in site1 you can do to redirect to site2 example: <?php…
-
1
votes1
answer81
viewsA: How do I make an interaction between two tables (<table>) with AJAX?
To know which line you have chosen you can do the following, in html: <table id="table"> <tr id="1"> <td>A</td> <td>B</td> </tr> <tr id="2">…
-
2
votes3
answers1606
viewsA: Count how many times a string appears in an Object
You can use the this function php example: $array = ['a','b','c','b']; $arrayCount = array_count_values(array_map('strtolower', $array)); $arrayCountB = $arrayCount['b']; // 2…
-
1
votes4
answers1061
viewsA: How to take the units of a two-digit number
You can use the function str_split() php $array = str_split($num);
-
0
votes2
answers78
viewsA: Does not connect to database and returns no error
Add the following lines to get the error: // verificar a conexão if (mysqli_connect_errno()){ echo "Falha ao conectar ao servidor: " . mysqli_connect_error(); }