Posts by KaduAmaral • 11,472 points
313 posts
-
4
votes2
answers884
viewsQ: What to write in an Exception Class (Exception)?
I was looking at that question at Stackoverflow en How can I write custom Exceptions? and the most well-voted (and accepted) response was: public class MyNewException extends RuntimeException {…
exceptionasked KaduAmaral 11,472 -
10
votes2
answers860
viewsQ: What are the Exceptions?
A little while ago I asked that question What are Exceptions and how should I create and embed them in PHP, but I did not have an answer that satisfactorily addressed the points raised. So I am…
-
3
votes1
answer156
viewsQ: Bug in PDO? Table disappears after INSERT command, how to debug?
Introducing I’m creating a library with some "magic methods" on top of PDO, already I did it with Mysqli and worked beautifully. The intention is to use in a Framework I am building, finally no more…
-
14
votes1
answer74733
viewsA: Problems with: Uncaught Referenceerror: $ is not defined
Missing to perform jQuery import, example: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script> Or download the file from the…
-
5
votes1
answer3509
viewsQ: Error when using bindParam: Only variables should be passed by Reference
I’m getting an error when I use the bindParam from the PDO, code: Connectionpdo class: function __construct($dsn, $username = NULL, $password = NULL, $options = NULL) { parent::__construct($dsn,…
-
2
votes4
answers399
viewsA: Select Option does not search or save the value selected by the user
This happens because the while kept changing the variable $marca1 throughout the loop, when the variable ended was with the last value of the loop, example: $i = 0; while($i++ < 10){ $marca = $i;…
phpanswered KaduAmaral 11,472 -
6
votes2
answers461
viewsA: How to sort the results of a ranking?
You could use either the TIME type or the INT or DOUBLE/FLOAT/NUMERIC type (depending on the database). Implementation of the type TIME (Mysql): CREATE TABLE rankingbytime ( id INT NOT NULL PRIMARY…
-
4
votes2
answers137
viewsA: Form safety
Most of your problems will be solved with some simple validations, example: <?php if(isset($_POST['subdate']) && !empty($_POST['date'])) { $daysOff = array(); $get_date = explode(',',…
-
2
votes5
answers19009
viewsA: How to keep the footer always down there
Footer at the bottom of the Document I usually use the following solution: First I calculate the height of the window windowHeight and from that height subtract the header height headerHeight and…
-
11
votes2
answers435
viewsQ: What are Exceptions and how should I create and embed them in PHP
I’m creating an MVC system and I want to implement Exceptions in my system. I’ve just never particularly used it. So I wanted to know how to apply the Exceptions, since I saw here in Stackoverflow…
-
2
votes2
answers737
viewsA: Change element with jquery
You are using the same ID id="quantidade" in various elements, Ids must be unique (not repeated). Change the element by removing the ID and placing a class, change the id="quantidade" for…
-
1
votes2
answers1887
viewsA: property registration php mysql
To make this implementation is relatively simple, but has something that needs to be taken into account, which is when the sum of the installments does not result in the total as in the case of a…
-
9
votes3
answers2984
viewsA: The ideal way to build forms is to use table or div?
The ideal is do not use tables, since the proposal for the table is for data tabulation, as if it were the visible form of a database table for example. In the documentation of W3C standards on the…
htmlanswered KaduAmaral 11,472 -
2
votes3
answers859
viewsA: Use explodes to separate categories
Assuming the content of $_GET['category'] be it for example: $_GET['category'] = "ação, comédia, romance"; You could do it like this: $categorias = !empty($_GET['category']) ? $_GET['category'] :…
-
2
votes1
answer330
viewsQ: How to go emptying PHP buffer while running
I’ve seen somewhere a code that configures PHP to go emptying the Buffer (print on screen) while running script without the need to wait all the execution for something to be displayed. Has anyone…
-
3
votes2
answers1724
viewsA: Change one combobox from another
You can create an object with the list of hotel relationships and their accommodations, example: jQuery(document).ready(function($){ // Objeto com as relações de hotéis e suas respectivas…
-
2
votes2
answers2439
viewsA: How to use the value of options?
To take the value of option selected just take the value of the select, after all who receives the attribute name is it, ie when you select some option you are defining that the value of select will…
-
1
votes4
answers258
viewsA: Doing level calculation and experience with Javascript
I commented well on the solution, but basically you need to make a loop "passing" to XP Wins to the XP of the Player and checking if the Player’s XP is enough for him to pass the level, if he is…
javascriptanswered KaduAmaral 11,472 -
1
votes1
answer1617
viewsA: Fill combobox with ajax
In your PHP use more "friendly" names to identify what does what. <?php if($funcao == 'filial') { $sql = "select codfilial, nome from filial where codempresa=$codempresa order by nome;"; $rst =…
-
1
votes3
answers1590
viewsA: How to add or subtract a digit in the Textbox via a button?
C# is not like PHP that performs operations with what lies ahead, it needs to work with certain types, and as you yourself expressed the value of the Textbox field is text (or string). To work with…
-
6
votes2
answers516
viewsA: All keys work as enter
You can check the size of the field value, if it is the size of the badge number, send the form, example: function SomenteNumero(e){ var tecla = (window.event) ? event.keyCode : e.which; if((tecla…
javascriptanswered KaduAmaral 11,472 -
0
votes2
answers73
viewsA: Array with inputs and a specific data!
An example of how to do implementation type is as follows: Form <form> <?php for($i=0;$i<5;$i++){ ?> <input type="text" name="foto[<?=$i?>]"><input type="radio"…
-
2
votes1
answer2856
viewsA: User-friendly URL with Nginx
Resolution: Your rule: rewrite ^/artista/([a-z]+) /artista.php?artista=$1 last; You are redirecting the URL: meusite.com.br/artista/nomedoartista To remove the snippet /artista/ of the URL, just…
-
0
votes1
answer226
viewsA: Error with javascrit in separate file
Instead of passing the ID, pass the element to the function: <asp:TextBox ID="txtLinhaDigitavel" runat="server" Width="390px" onFocus="javascript:this.select();"…
javascriptanswered KaduAmaral 11,472 -
7
votes2
answers335
viewsQ: How to verify that the document markup is HTML5?
I am creating a plugin and need to know if the document is written in HTML5 or not. I thought I’d use the document.doctype, but I don’t know what to compare it to since I compare it to '<!DOCTYPE…
-
5
votes2
answers10669
viewsA: As local network localhost address
Local Network Access (LAN) If you are on the same network you can use the server name. To know your computer name on Windows Open the Command Prompt and type hostname: In my case it is DEV004W, then…
-
7
votes2
answers1905
viewsA: How do I get the browser user’s language?
Translation of Response to How to get the page Visitors Country with PHP? You can use an external API such as geoplugin.net $xml =…
-
3
votes1
answer222
viewsA: What is the best practice to restrict access to the website’s administration system?
There are many practices that can raise the security level of a system. I’ll be listing some of the most common and important. Strength of Passwords A very recommended practice is to recommend/force…
-
1
votes3
answers1481
viewsA: How to create a mini database written in php using a text file in json format
To work with this type of functionality, a recursive function is the easiest way to do it, for example: JSON file: { "users": { "mariana": "offline", "joao": "online" } } PHP function function…
-
0
votes4
answers1021
viewsA: Add minutes to the hour
The Moment.js is a great tool to work with dates in Javascript. It has several very useful features. Follow some examples with addition. var now = moment(); console.log(now.calendar());…
javascriptanswered KaduAmaral 11,472 -
4
votes4
answers966
viewsA: hyperlink mailto on button
A possible solution is to use Javascript: document.getElementById('sendmail').addEventListener('click', function(event){ event.preventDefault(); document.location.href = 'mailto:[email protected]';…
-
3
votes2
answers1199
viewsA: HTML with bootstrap responsive layout
The formula for fixing container height is quite simple: WindowHeight - MenuHeight - FooterHeight That is, the height of the window, minus the height of the menu and footer, with the side menu is…
-
7
votes2
answers1636
viewsA: Why do we have to use ? > <?php when we use Eval in the content of a php script?
How does the eval: The eval executes a string as a normal PHP execution, example: $x = 2; $y = 3; $z = eval('return $x + $y;'); eval('echo $z;'); The above example will print 5 on the screen,…
-
2
votes1
answer52
viewsA: Data cut in mysql
This is because the size of your column (probably a VARCHAR with size 255) is limiting the amount of characters that can be registered in the table. To resolve this, change the column type to TEXT.…
-
-1
votes1
answer54
viewsA: Function for file upload
After the code block: foreach($_POST as $key => $val){ //Percorre os indices passados por POST armazanando em $key e os valores em $val $campo[] = $key; // Cria um array $campo com os indices…
-
4
votes1
answer746
viewsA: Switch varialvel to modal
On your display page do so: <table class="table table-bordered table-hover center-text" name="carrtab" id="carrtab" style="background-color: #ffffff;"> <thead align="center"> <tr…
-
0
votes3
answers96
viewsA: Doubt how to use a Less class with RAZOR
This functionality already exists in HTML, it is well known as CSS inline. Example: th {background-color:#444; color:#FFF;} <table> <tr> <th style="min-width:80px;">Col…
-
1
votes1
answer973
viewsA: Subscribe button from youtube
The Google Developers has a page to create this button, just access Youtube Subscribe Button. An example button to subscribe to the Google Developers channel: <script…
-
3
votes2
answers1128
viewsA: How to concatenate php variable to pass as parameter
In PHP there are some ways to encapsulate strings the main ones are using the "string" (double quotes) and also 'string' (single quotes) and they are not the same thing. The double quote searches…
phpanswered KaduAmaral 11,472 -
1
votes2
answers879
viewsA: Load javascript depending on the viewport?
A viable solution is to detect the user-agent and determine whether it belongs to a mobile browser or not. The website Detect Mobile Browser possesses scripts in various languages. Example in PHP:…
-
2
votes1
answer56
viewsA: Return a variable value with Zeroclipboard
Just look at the library documentation. var client = new ZeroClipboard( document.getElementById("d_clip_button") ); client.on( "copy", function (event) { var clipboard = event.clipboardData; // Pode…
-
0
votes1
answer122
viewsA: Recover ID passed by DIV on next page
As comments, to save the information use cookies or Local Storage: $(document).on('click', '#ListandoCidades a', function(event){ event.preventDefault(); // Evita que o navegador navegue para o link…
-
4
votes2
answers301
viewsA: The space key also becomes a character? LENGHT
Yes the space is a character "blank", ie a space. You can get around this type of problem by making a trim in string: $('.butSend').click(function() { var mensagem = $("#userChat").val().trim(); var…
-
7
votes2
answers1091
viewsA: Put spacing effect at paragraph start
You can use the property text-indent: p { text-indent: 50px; } <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.…
-
2
votes2
answers200
viewsA: Centralize dynamically created div on top of another div
As already mentioned in the comments, just calculate the offset: var $mc = $('#main-content'); // Seleciona o elemento div#main-content var $wd = $('#windows'); // Seleciona o elemento div#windows…
-
3
votes2
answers339
viewsA: PHP - Problem with search return INNER JOIN with GROUP BY!
My query may be a bit complex, but that’s what I got without being familiar with the system and modeling. SET @user = 2; SELECT * FROM ( SELECT z.id, u.nome_us, -- u.foto, -- u.username,…
-
1
votes1
answer592
viewsA: Problem with form (GET method) and URL Friendly
Just add to flag [QSA] (Querystring Append): RewriteRule ^([^/]*)$ index.php?page=$1 [QSA] RewriteRule ^([^/]*)/$ index.php?page=$1 [QSA] RewriteRule ^(.*)$ $1.php [QSA] Source It can also simplify…
-
7
votes3
answers18194
viewsA: What purpose of unsigned in C++
Data types marked as unsigned means that they will accept only positive values (including 0). Various types of data can be marked as signed or unsigned: Tipo de dados Tipo de assinatura padrão…
-
4
votes1
answer765
viewsA: How to position two selects within the same div?
You can use columns <div class="col-md-6"> inside the columns. Don’t put the selects within the labels. Use the class form-control us selects. <script…
-
5
votes2
answers528
viewsA: What is the difference between new Function and Eval?
val The Eval() method evaluates Javascript code represented as a string. MDN Function The Function constructor creates a new Function Object. In Javascript Every Function is Actually a Function…