Posts by Papa Charlie • 8,721 points
217 posts
-
17
votes1
answer105429
viewsA: Insert line break (enter) using HTML codes
jsfiddle Use 
 for line breaking <a title='1ª linha
2ª linha
3ª linha'>link</a> output 1ª linha 2ª linha 3ª linha source…
htmlanswered Papa Charlie 8,721 -
1
votes1
answer2243
viewsA: How to insert XML data within a MYSQL database?
I recommend you tidy up this XML for a more practical way and avoid repeating nodes. Note that even your CDATA contains undue spaces, to remove them use the function TRIM Maybe the best option is…
-
4
votes4
answers1688
viewsA: Fill fields of a multidimensional array with null
array_walk - Apply a certain function to each element of an array array_walk( $arrays , function( &$array ){ foreach( $array as $item => &$value ) { if( ! $value ) $value = '0'; } });…
-
1
votes1
answer136
viewsA: How to convert characters within XML?
Just use utf8_decode echo utf8_decode( 'dormitórios' ); Output: dorms…
-
4
votes2
answers543
viewsA: On-demand content problems (Infinite scroll)
I made an example calculating the distance of the div Loader in relation to the screen. When the Loader enter the screen, the content will be loaded. In the example I simulate a page with height of…
-
2
votes2
answers114
viewsA: Problem returning the size of a file with PHP and Curl
I made a simple example below using jQuery’s JS. $url = 'http://code.jquery.com/jquery-1.11.1.min.js'; $ch = curl_init( $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch,…
-
1
votes2
answers165
viewsA: How to define access levels
I recommend PDO for numerous advantages. You decide, but like @Jorge B. spoke, avoid mysql_. I am giving an example with PDO. // Exemplo de conexão com PDO: $pdo = new \PDO(…
phpanswered Papa Charlie 8,721 -
4
votes1
answer378
viewsA: div that does not exceed certain limits
Online example on jsfiddle. I made an example as clean as possible to allow adaptation. HTML <div class="div1"></div> <div id="nav"> <ul> <li><a href="#">Link…
-
1
votes1
answer80
viewsA: Protect pages that are loaded inside the template - Kohana
I’ve had very superficial contact with Kohana, I don’t know the details, but in a way generic model-based MVC, I can make some considerations that may help. There is the possibility to do this in…
-
9
votes2
answers99
viewsA: Menu in lower tab form
JS and jsfiddle updated I did an online example on jsfiddle. I assume you intend to take actions, and that’s a record listing, so I referenced the ID of the DIV with the registration ID. With it you…
javascriptanswered Papa Charlie 8,721 -
3
votes2
answers687
viewsA: $_Session variable does not write to database
Updating I was reviewing a code pad and I remembered a combination of http_build_query and parse_str which may be useful to your case. $_SESSION['session.A'] = 'Meu valor para A';…
-
6
votes2
answers27161
viewsA: How to destroy a specific session?
Updating You can do subgroups in the session: $_SESSION['login'] = array( 'email' => '[email protected]' , 'senha' => 'userpassword' ); $_SESSION['games'] = array( 'palavra' => 'Helicóptero'…
-
1
votes1
answer1844
viewsA: How to move element randomly across the screen (css or jquery)?
I made an example at jsfiddle adapted as a basis this answer. JAVASCRIPT $(document).ready(function() { $('.bouncer').click( function(){ alert('clicaram no: ' + $(this).attr('title')); }); });…
-
5
votes2
answers955
viewsA: Merge array by replacing equal results
Function to reduce equal occurrences var unique = function(a) { return a.reduce(function(p, c) { if (p.indexOf(c) < 0) p.push(c); return p; }, []); }; Concatenating and replacing the repeated…
javascriptanswered Papa Charlie 8,721 -
3
votes2
answers5639
viewsA: Rescuing the last insertion in the bank with lastInsertId PDO
Without replicating your code... Run lastInsertId before commit. It’s a reported case and you can read here in PHP. try { $dbh->beginTransaction(); $stmt->execute(array( ... )); echo…
-
6
votes3
answers2982
viewsA: Find out if a website is on or off
1) Using fsockopen, note the format of the URL if( fsockopen( 'www.locaweb.com.br' , 80 , $errno , $errstr , 30 ) ){ echo 'site online!'; } else { echo 'site offline.'; } 2) Using checkdnsrr: Checks…
-
8
votes2
answers1101
viewsA: How to know if the calculation generated an integer?
parseint (reference) divisao = 10/2; if( divisao === parseInt( divisao ) ) { alert("10/2 resultou em inteiro") } else { alert("10/2 não é um inteiro") }…
javascriptanswered Papa Charlie 8,721 -
4
votes2
answers26487
viewsA: Best way to make a script to logout
Generally login is a combination of sessions and cookies that guarantee the authenticity of the user even after the browser closes. Assuming a simple login system with unique use of sessions, you…
-
3
votes2
answers2817
viewsA: Merge two tables with PHP
INNER JOIN EXAMPLE SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name; Based on their tables SELECT * FROM posts INNER JOIN users ON posts.id = users.id…
-
2
votes4
answers2214
viewsA: SQL query return total of days in a month on two dates
Well, I’m not sure I understand your doubt, but come on... QUERY SELECT DATEDIFF( '2014-06-03' , '2014-05-25' ) AS DIAS , ID FROM MYTABLE WHERE IDFUN = 1 RESULT array( 'DIAS' => 9 , 'ID' => 1…
-
2
votes3
answers1523
viewsA: How to access one selector within another in jquery?
I made an example at Jsfiddle and completed the others div's with text to illustrate. // troque pela linha abaixo $('.contentParagraph').fadeTo('fast',0) // Para ele aplicar o efeito no elemento…
-
3
votes3
answers1513
viewsA: Is there an application security flaw when using AJAX?
My question is whether the security level is affected when passing parameters by AJAX since the javascript source code is exposed [...] The variables inside PHP, they are kind of discovered already…
-
3
votes1
answer555
viewsA: Make my site appear on the Google news listing
All you need to know is here in the link. Basically you register your site as editor. The doc in the link above has all explanation and the doc in the link at the end is for editor registration. How…
-
2
votes1
answer100
viewsQ: Connections and management
PHP - PDO, Connections and Connection Management The connection remains active throughout the lifetime of the PDO object. To close the connection, you need to destroy the object, ensuring that all…
-
14
votes6
answers1673
viewsA: Big job or small job?
I produce in OOP, and learned to divide into methods. So they can be reusable whenever necessary... **DRY** In my opinion, large functions generate dirty code. The chance that you have very similar…
-
3
votes2
answers1814
viewsA: How to access the COOKIE on another page?
PHP Explica Once the cookie has been set, it can be accessed on the next page through the $_COOKIE arrays You have successfully created the cookie: setcookie( 'nome' , $dataNome , time() + (2 *…
-
3
votes3
answers759
viewsA: Comparison between a numeric string and an alphanumeric string
Compare === does not solve, see that 0xFA is 250, so ( 250 === 0xFA ) results in TRUE 1) Compare the size of a string to an input that is: 0xFA if( $string <= 255 ) // 250 < 255 // Logo…
-
1
votes3
answers1452
viewsQ: Validate URL with ER
I have a validation class and need a method to validate URL’s, but the function filter_var contains flaws to validate them. An example of 3 Urls: The URL is complete returns TRUE #1…
-
6
votes2
answers2155
viewsA: Header running over Echo
PHP-HEADER Remember that header() should be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common mistake to read code with…
phpanswered Papa Charlie 8,721 -
11
votes3
answers326
viewsA: How to make a function where every time a variable is called is increased by 1?
Another possibility would be using magical methods. example $counter = new Counter(); echo $counter; echo $counter; echo $counter; echo $counter, $counter, $counter; output 123 class class Counter {…
phpanswered Papa Charlie 8,721 -
1
votes3
answers248
viewsA: Display images from right to left
Just completing with another way of doing. Using the attribute dir="rtl". Made just to direct the text - DIR-ESQ | ESQ-DIR, used to align the layout for languages written from right to left. <div…
-
0
votes2
answers659
viewsA: Add thousandths to jquery counter
source Returns milliseconds according to local time var millisecond = new Date().getMilliseconds(); hours = new Date().getHours() minutes = new Date().getMinutes() seconds = new Date().getSeconds()…
-
6
votes3
answers13793
viewsA: Date in dd/mm/yyyy format?
Optimizing your query counter: Your query does not count, it returns ALL records!!! SELECT * FROM cartao The right thing would be: SELECT COUNT(*) AS count FROM cartao LIMIT $inicial, $numreg My…
-
0
votes2
answers440
viewsA: Select only 1 record with the same category and Hidden in the other
I ran tests with the example and it’s running as you explained. I tried to comment on the code as much as possible in a simple way. $limit = 10; $counter = 1; $categoria = null; while( ... ) { //…
-
2
votes2
answers1870
viewsA: How to redirect www.subdominio.dominio.com to http://subdominio.dominio.com?
See if this rule solves RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L] Reference!…
-
5
votes2
answers14096
viewsA: How to display echo quotes in PHP?
You need to escape ". $nomes = 'nomes...'; echo "<a href=\"#excluir\" class=\"button icon-trash\" onclick=remover_musica_ftp( 0 , \"$nomes\" ); title=\"Excluir\">link</a>"; Output <a…
-
5
votes2
answers544
viewsQ: Rank database [#1 of 10]
I need to rank the DB records during paging. I don’t intend to create a field for ranking at first. Assuming I have 10 records 1) Ordenando a paginação por AZ, quero listar com o número…
-
3
votes1
answer143
viewsA: Script code function
In your code is removing the cookie, the date is to force the removal. • useHTML5 = '' • expires = Thu, 01 Jan 1970 00:00:01 That is to say, useHTML5 without an assigned value - null, and the date…
-
1
votes2
answers3250
viewsA: How to submit form without being redirected by the action attribute?
Giving a very simple example to the case, passing via POST js $('form[name="NOMEDOFORM"]').submit( function(){ event.preventDefault(); $.ajax({ url : 'page.php', type : 'POST', data : { campoA :…
-
1
votes2
answers161
viewsA: Result of a function in an array
You could use a GETTER... is ugly and dirty, but take as a didactic model. If you can give some more information about class behavior it is easier to give a real example. class MyClass { public…
phpanswered Papa Charlie 8,721 -
0
votes1
answer180
viewsA: Align table with header
Basically is: // CSS h1{background:#FF0000} table{background:#FFCC00} // HTML <h1>Heading</h1> <table style="width:300px"> <tr><td>Teste</td></tr>…
-
2
votes4
answers723
viewsA: How to create a link that when clicked is added a CSS property in a div?
I made a simple example where the control is based on the text of the element, without the control by variables - it’s just one more possibility since you control the text by jQuery.…
jqueryanswered Papa Charlie 8,721 -
1
votes1
answer184
viewsA: Doubts about SEO
Urls www.dominio.com/noticia1234.htm www.dominio.com/noticia/politica-no-brasil.htm Taking the example of the DOC... it is obvious, but the separation must be relevant and coherent relating the link…
seoanswered Papa Charlie 8,721 -
1
votes3
answers729
viewsA: Login and password submit!
You don’t have to use $("#fazerloginform").submit() if the answer is true. See if this example helps... $('form[name="NOMEDOFORM"]').submit( function() { event.preventDefault();…
-
13
votes2
answers938
viewsA: I have a multi-language site, in the matter of SEO which is better: Using Subdomains or Directories?
Take the example of Twitter and Facebook, they do not change the domain. No matter what language the user chooses, I don’t think it should be passed as a parameter in the URL. In my view, the…
seoanswered Papa Charlie 8,721 -
1
votes3
answers2040
viewsA: PHP Table background color
Assuming that your $row[2] is a date in the format 07/08/2014 if( time() > strtotime( $row[2] ) ) ... . I recommend the use of PDO . Contrary to popular belief, tables should not be abolished.…
-
2
votes2
answers148
viewsA: What precautions should be taken when sending an email via PHP
Form does not connect to the database, it only provides the information that will be inserted into the DB. You need to validate before saving the information, check if what you received is of the…
-
1
votes3
answers3361
viewsA: Configuration of . htaccess to access several PHP files within the same folder
.HTACCESS RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} \.php$ RewriteRule (.*) index.php [QSA,L] ROUTE // www.meusite.com/categoria/produtos/2 ->…
-
1
votes3
answers319
viewsA: How to display an ajax error through a url?
I’ve put together a very superficial example for your login case. I suppose you already have the form, just change the field names. LOGIN.PHP <? // PDO - select user // senha inválida echo false;…
-
1
votes3
answers795
viewsA: creating a group of random numbers that are unique
You can use microtime microtime - Returns a Unix timestamp with microseconds Depending on the purpose it can be a simple and viable alternative and with low risk of collision. echo microtime();…
phpanswered Papa Charlie 8,721