Posts by Yure Pereira • 3,971 points
117 posts
-
2
votes1
answer900
viewsQ: How to traverse lines of a SELECT in a STORED PROCEDURE in SQL Server?
Other than with the use of CURSOR and WHILE in the SQL Server, what other ways it would be possible to traverse the result lines of a SELECT in a STORED PROCEDURE?…
-
0
votes1
answer358
viewsQ: How to set the boot value of a PRIMARY KEY field set to IDENTITY in SQL Server?
In Mysql when creating a table with an AUTO_INCREMENT field being PRIMARY KEY it is possible to define what will be the initialization value of the first record of the same, as follows the script…
-
1
votes2
answers6364
viewsA: How to make an element track the scrollbar?
Use position: Fixed; on the selector #menu. var nav = document.getElementById("menu"); var showMenu = document.getElementById("abrir"); var hideMenu = document.getElementById("fechar");…
-
5
votes2
answers380
viewsQ: How to transpose the result of a search using SQL Server?
Or better saying how to make the columns of a search result SQL Server, become lines of the result, as follows in the images below: A search result using the clause select whichever: Make the result…
-
7
votes2
answers34966
viewsA: What is the correct way to use the Location header?
The error found in the code you posted in the question is in the way you are calling the header function, where instead of using parentheses you are using brackets. Wrong shape: header["location:…
-
7
votes1
answer815
viewsQ: How to set the maximum disk size of a database?
How to set the maximum disk size of a Mysql, Oracle, Postgresql or DB2 database? This is how I do in SQL Server: Create Database MyDatabase on (Name='MyDatabase_Data',…
-
2
votes1
answer782
viewsA: Remove Blank lines in a Csv file
Do it this way: <?php $or = fopen("output.csv", 'r'); $nv = fopen("novo.csv", 'a+'); while (($line = fgetcsv($or, 5000)) !== false) { if (count(array_filter($line)) > 0) { fputcsv($nv, $line);…
-
1
votes2
answers1621
viewsA: mPDF - Error generating PDF | Message: preg_replace():
Try to use as follows to not display the error, but you could also update the library to its latest version: error_reporting(E_ALL ^ E_DEPRECATED); $this->load->helper('mpdf');…
-
0
votes5
answers1382
viewsA: No return on method?
Try to do as follows by concatenating line by line: public static String addItemCreative(File f) { String line, lines = ""; try { BufferedReader br = new BufferedReader(new FileReader(f)); while…
-
2
votes3
answers72
viewsA: Page does Submit even with validation error
You can do it this way: $("#botao1").click(function(e) { e.preventDefault();//Para o envio do submit if (validar()) { $.ajax({ url : 'adicionadaIdeia', type : 'POST', async : false, data :…
-
2
votes2
answers172
viewsA: How to select one element from another
Do so: $('select[name="sys_nivel_acesso_id"]').siblings('div').find('button'); Html: <select class="form-control dropup bs-select-hidden" name="sys_nivel_acesso_id"></select> <div…
jqueryanswered Yure Pereira 3,971 -
4
votes2
answers188
viewsA: Syntax error in Javascript
Removes the var and the [] function parameters combinationUtil, because the way it is it makes a syntax error. function combinationUtil(arr, data, start, end, index, r) { if (index == r) { for (var…
-
1
votes2
answers984
viewsA: Codeigniter session expiring after an action
To try to solve this problem try to increase the time the sessions are updated in the configuration variable sess_time_to_update, thus: $config['sess_time_to_update'] = 86400;// 24 horas Also check…
-
3
votes1
answer1113
viewsA: Set default value for database column in Laravel 4
Does so by calling the default method in a chained form: Schema::create('tabelaTeste', function ($table){ $table->increments('id'); $table->string('coluna1', '50')->default('valor'); });…
-
0
votes2
answers899
viewsA: Configuration of . htaccess not working
You can do as follows by removing the / from the beginning if your site is not at the root, because when you put the / at the beginning refers to the root of the site, so for example:…
phpanswered Yure Pereira 3,971 -
20
votes2
answers52864
viewsA: How to check if the Term is contained in String in PHP?
This can be done as follows with regular expression in PHP: <?php $tags = 'canais,proteses,implantes'; $termo = 'proteses'; $pattern = '/' . $termo . '/';//Padrão a ser encontrado na string $tags…
-
1
votes1
answer1283
viewsA: How to put variable inside quotes in javascript?
As follows, by placing the variable in [ ], without the need to quote: var TOTAL_VISIT_PAIS = '1111'; //jvectormap data var visitorsData = { "US": 398, //USA "SA": 400, //Saudi Arabia "CA": 1000,…
-
0
votes1
answer51
viewsA: Send data to database
Changes the Save method to the form below, as there is a simple error where you are disconnected from the database before running the Insert on it: public void Salvar() throws SQLException { try {…
-
11
votes3
answers14671
viewsA: What is the difference between Statement and Preparedstatement?
The difference between them is that you can use Statement when you intend to execute fixed SQL statements, i.e., plain text instructions, such as the following: Statement stmt =…
-
3
votes3
answers66
viewsA: Class attribute does not generate error when commented
This is due to PHP allowing to be create class members dynamically at runtime, where you can avoid this using the magic method __set, as in the following example: <?php class Usuario {…
-
3
votes1
answer22
viewsA: Accessing an array that is inside another
As follows: echo $seuArray[0]['data']; echo $seuArray[1]['data']; Or for a tie for: for ($i = 0; $i < count($seuArray); $i++) { echo $seuArray[$i]['data']; } Or with foreach loop:…
phpanswered Yure Pereira 3,971 -
0
votes2
answers667
viewsA: how to go through all elements of a php array with javascript
Here’s an example of how you could do this using php’s json_encode function: <?php $nomes = array( 'nome1', 'nome2', 'nome3', 'nome4', 'nome5', ); ?> <script type="text/javascript"> var…
-
1
votes1
answer2299
viewsA: JS + HTML Image Preload
A way to promote images with javascript would be as follows below, where I am taking advantage of part of your code: var colors = […
-
2
votes1
answer226
viewsA: Treat request redirected by Htaccess
One way you could do this is this, where . htaccess would look like this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]…
-
1
votes2
answers409
viewsA: Convert date format
You could do this as follows to format the fields: <?php //Formatar data $data = '11/20/2015'; $dataParts = array_reverse(explode('/', $data)); //echo implode('/', $dataParts);//01/11/2015 //Para…
phpanswered Yure Pereira 3,971 -
1
votes3
answers596
viewsA: How to arrange the date order?
You could do it this way using the Datetime class: <?php $data = '2015-11-01'; $date = new DateTime($data); echo $date->format('d-m-Y');//01-11-2015 Or also using regular expression: $pattern…
-
0
votes2
answers880
viewsA: Removing a part of the text inside a txt file
So you can remove the tag br of the final txt file, you could do as follows by changing the following code code: $trocar = preg_replace("<br>",null,$leituraFinal); To: $trocar =…
phpanswered Yure Pereira 3,971 -
6
votes4
answers4258
viewsA: How to prevent direct access to my PHP code?
You could do this by creating a folder where all your acquisitions are protected and inside that folder you would create a file .htaccess putting this instruction below inside it, which causes…
phpanswered Yure Pereira 3,971 -
2
votes3
answers699
viewsA: Search word with file_get_contents
It can be done in the following ways, and it also has many other forms: In the first one going line by line and giving echo in the words found: <?php $fileContent =…
-
2
votes15
answers4487
viewsA: Determine if all digits are equal
You could do it this way using recursion: Example in Java: public static boolean allDigitsEqual(int x) { String xStr = Integer.toString(x); if (xStr.substring(0, 1).equals(xStr.substring(1, 2))) {…
-
1
votes3
answers46
viewsA: Disable a FUNCTION on mobile
You could do it this way: $(window).resize(function() { if ($(window).width() > 1200) { $(window).scroll(myFunction); } else { $(window).unbind('scroll'); } }); var myFunction = function() { //…
-
1
votes3
answers4422
viewsA: How to toggle text between "show / hide" inside a javascript button
You could do as follows using the tennis operator and passing the button reference by parameter with this to be able to change the text of the text. function Mudarestado(el, btn) { var ele =…
javascriptanswered Yure Pereira 3,971 -
0
votes5
answers267
viewsA: Store arithmetic operator in variable
You could also do as follows using object orientation, where all the complexity lies by responsibility of the class Calculator solve, thus making its use much easier, so much so when the future…
-
5
votes3
answers294
viewsA: How to relate category instance to a product instance in PHP
You could do as follows using encapsulation, where to be set all class properties as private or protected(If there is an inheritance relation) and be create the methods that have become responsible…
-
2
votes3
answers5031
viewsA: Error formatting ZIP code
Change the regular expression to that form: /^([\d]{2})\.?([\d]{3})\-?([\d]{3})/ Where the metacharacter ? indicates in this expression that the existence of characters . e - are not required for…
javascriptanswered Yure Pereira 3,971 -
4
votes1
answer98
viewsA: Regular Expression
You can do it this way: public class Validator { public static boolean validarTexto(String texto) { Pattern p = Pattern.compile("\\<{3}(\\w+)\\>{3}"); Matcher retorno = p.matcher(texto);…
-
2
votes4
answers8633
viewsA: SQL query comparing two fields of the same table
You can do it this way: select ra, nome, cod_curso, max(serie) as serie from alunos group by ra, nome, cod_curso Another way without having to put all the fields in Gruop by: select a1.* from alunos…
-
7
votes6
answers1359
viewsA: How to insert an if/Else into an echo?
You can use if ternário, like this: <?php $selected = $resultado['status'] == 1 ? ' selected="selected"' : ''; echo '<option value="1" ' . $selected . '>Publicado</option>'; echo…
phpanswered Yure Pereira 3,971 -
-1
votes2
answers12596
viewsA: Get general project directory, php
You can do it this way: <?php $raiz = $_SERVER['DOCUMENT_ROOT']; require_once $raiz . '/outrapasta/file_require_1.php'; require_once $raiz . '/outrapasta/file_require_2.php'; Where the predefined…
phpanswered Yure Pereira 3,971 -
0
votes2
answers797
viewsA: case and minuscule differences in the URL
You could do it this way: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ $1 [NC] </IfModule>
-
0
votes1
answer138
viewsA: Warning message
You could use jQuery with some plugin, for example I’m using jquery.modal.js:, but there are many plugins available on the internet, and only search by jquery model plugin. <!DOCTYPE html>…
javascriptanswered Yure Pereira 3,971 -
4
votes3
answers2891
viewsA: What is the need to maintain a`name` attribute in a`HTML`tag?
These are the names of the parameters that are sent in a GET or POST request. In HTML: <form class="" action="index.php" method="post"> <input type="text" name="name_input_1" value="">…
htmlanswered Yure Pereira 3,971 -
4
votes2
answers329
viewsA: select Pdo com oo
Do it this way using the Book class as an example I created in another issue using this same database class: class LivroDAO extends database { public function __construct(){} public function…
-
0
votes3
answers158
viewsA: How to reuse the connection in the subclass?
As the Connect class is being inherited by the Methods class, you can do it as follows using Parent which is a reference to the parent class in an inheritance relation: parent::conectar(); How would…
-
3
votes1
answer1120
viewsA: Insert with Pdo and OO
You can do so by creating a class where it will inherit the database class, as in the following example where I created the Free class: <?php class LivroDAO extends database { public function…
-
1
votes5
answers3766
viewsA: Java - simple program (finding cousins) - does not run
You could do so by making a Static isPrime method, so that your code becomes simpler, organized and readable: public class Main { public static void main(String args[]) { for (int i = 1; i <=…
javaanswered Yure Pereira 3,971 -
5
votes3
answers1488
viewsA: Cut text and add ellipsis
You can do it this way: <?php function text_limiter_caracter($str, $limit, $suffix = '...') { while (substr($str, $limit, 1) != ' ') { $limit--; } if (strlen($str) <= $limit) { return $str; }…
phpanswered Yure Pereira 3,971 -
2
votes2
answers1457
viewsA: Doubt, java regular expression
Do it: public boolean validarCaminho(String caminho) { Pattern p = Pattern.compile("[a-zA-Z0-9\\.\\/]+"); Matcher retorno = p.matcher(caminho); return retorno.matches(); }…
-
2
votes4
answers1466
viewsA: Camelcase conversion function
You can do it this way: <?php function toCamelCase($str) { $newStr = ''; //$str = preg_replace('/[`^~\'"]/', null, iconv('UTF-8', 'ASCII//TRANSLIT', $str)); $pieces = explode('-', $str); for…
-
3
votes1
answer107
viewsA: Javascript - Capture src by class name
It can be done that way: var image = document.getElementsByClassName('Picture'); console.log(image[0].src); What you are wrong is called the getElementByClassName function that is misspelled missing…
javascriptanswered Yure Pereira 3,971