Posts by rray • 66,288 points
1,220 posts
-
1
votes1
answer118
viewsA: Code does not enter if when it should
It is necessary to pass the form to the function validaFrm(), this call can be made in the onsubmit of the form. o this means that you are passing the element itself (in this case the form) to the…
javascriptanswered rray 66,288 -
2
votes4
answers5851
viewsA: How to order a Mysql search with date in d-m-Y format?
Just add the format with date_format() in the field list and then sort: SELECT date_format(data, '%d/%m/%Y') FROM datas ORDER BY data DESC…
-
0
votes3
answers853
viewsA: MYSQL How to order this date field
I believe that convert these columns to a date field with str_to_date() solve the sorting problem: SELECT str_to_date(concat(ano,'-',mes,'-', dia), '%Y-%m-%d') as nova_data FROM datas ORDER BY…
-
2
votes2
answers1288
views -
3
votes2
answers2943
viewsA: Deprecated Error: Function ereg()
ereg_* was marked as obsolete (deprecated) in PHP 5.3. To fix this error, simply switch to preg_match. For example: ereg("^[a-zA-Z0-9\-_]{3,20}$", $nombre_usuario) Exchange for: if…
-
4
votes4
answers28928
viewsA: Calculator in php
To access form values use the syntax below. $a = $_GET['nome_do_campo_html'] and not $a = $_GET "num1";
-
1
votes1
answer616
viewsA: Open Excel file in BINARY_SAFE
With phpexcel it is possible to load and manipulate the spreadsheet, taking as an example a sheet with two columns name and email, and the following lines: 1 - A B 2 - joão da silva [email protected] 3…
-
5
votes2
answers266
viewsA: Help to write code
To transcribe this program to c language, a method is first required main which is equivalent to instruction programa <nome> the instructions leia and escreva should be replaced by printf and…
-
13
votes5
answers41336
viewsA: Number formatting (PHP)
In PHP 5.3 there is already one class for currency formatting. The first argument of NumberFormatter() is the currency that is based on ISO 4217 $valores = array('530077.99','31459.89', '2899.39',…
-
1
votes3
answers210
viewsA: Undefined variable when updating Database
The variable $AcidenteAnexo is undefined because your if is returning false, as it only begins to exist within it, so if the if condition is not satisfied $AcidenteAnexo there will be no. if…
-
3
votes1
answer145
viewsA: Invalid variable
If the function definition is within the while error will be issued: Fatal error: Cannot redeclare: apresentarAlvara. First you should declare the function at the beginning or in another file. See…
-
0
votes3
answers192
viewsA: How to write an array post in current Intel - input file
To check if there is any upload(file), you use $_FILES and not $_POST. if (isset($_FILES['file1']) && $_FILES['file1'] != ''){ //update }…
-
1
votes1
answer107
viewsA: Returning null value when creating table in Wordpress
I tested the structure of your table directly in the database and returned the following error: Error Code: 1075. Incorrect table Definition; there can be only one auto column and it must be defined…
-
6
votes2
answers2087
viewsA: How to pass arguments to a PHP script via command line?
To take the names and values of the arguments from the command line use $argv command line: php cmd.php -p1 v1 -p2 v2 cmd.php print_r($argv); Being that the first item of $argv is the name of the…
-
2
votes4
answers1506
viewsA: Direct method call in instance
This functionality, Class Member access on instantiation, is only available in version 5.4 or higher of php. Your code should look like this: echo (new Pessoa('Vinicius'))->getNome();…
-
1
votes2
answers225
viewsA: Transform code to Eval()
If you want data.php be processed by the server pass it as a url, to file_get_contens(). $data = file_get_contents('http://localhost/projeto/template.php'); I made an example trying to simulate your…
-
0
votes3
answers444
viewsA: How to standardize the formatting of javascript and php codes?
For php there are some recommended proposals that are: PSR-0, Regulates the definition of namespaces, so that the way to load (autoload) classes is an independent standard of the framework/lib used,…
-
6
votes1
answer25983
viewsA: How to run PHP file from Javascript function?
For a javascript to run a . php it is necessary to use ajax in this example it is necessary to add the library jquery to function properly. This code does not work because php is processed first and…
-
6
votes2
answers160
viewsA: INSERT INTO Does not send data to database
In your query string, remove the variable $con, changing $sql = ($con, "INSERT INTO Entregas (dia, cliente, toalhetes, higienico, bidons) VALUES ($dia, $cliente,$toalhetes, $higienico, $bidons)");…
-
0
votes7
answers175
viewsA: Contact Form
use smaller and not different, different may be larger or smaller. if (strlen($phone) < 9){ echo 'informe um numero de 9 digitos'; }
-
1
votes2
answers443
viewsQ: Paging results in SQL Server 2000
Sometimes I need to make queries in SQL Server 2000 and paginate the results but there is only the clause TOP that limits the number of records returned without an interval (offset) other banks like…
-
15
votes4
answers3280
viewsA: Integer with 0 to the left is printed as another number
Numbers started with zero, since valid, are interpreted based on 8 (octal), ie, 02345674 was interpreted on the basis of 8 and its representation on the basis of 10 is 641980. The warning manual on…
-
2
votes4
answers1172
viewsA: How to get values separated by "<BR>" in Mysql?
Exchange the <br> for \n using the function replace() mysql SELECT replace(campo, '<br>', '\n') FROM tabela…
-
5
votes2
answers473
viewsA: How do I use echo in a query with Prepared statement?
If the goal is to see the corresponding values the queries that substitution function. function setValor($consulta, $valores){ $count = substr_count($consulta, '?'); $interrogacoes = array_fill('0',…
-
10
votes4
answers10727
viewsA: What is the Mysql CREATE VIEW command for?
Serves to create a 'read-only table/virtual table that is based on queries. Can act as a shortcut to long queries. Instead of putting this query in several places in the code SELECT p.nome,…
-
1
votes3
answers554
viewsA: Get the structure of a table through a query
This information may be obtained through information_schema SELECT * FROM information_schema.columns WHERE table_name = 'nome_da_tabela' form open: describe nome_da_tabela…
-
2
votes3
answers6755
viewsA: How do I receive the $_GET value of a URL in Codeigniter
In the editar_user() define an argument for example $id, when the user clicks on the link the value 5 will be assigned to $id public function editar_user($id){ echo $id;…
-
1
votes2
answers452
viewsA: How to make the return of a query (PDO) bring me an array already?
To query a PDO array in the manually ordered structure create a new array($saida) and add the elements according to the key(periodo) //array na estrutura do PDO $entrada = array( 0 =>…
-
1
votes4
answers2192
viewsA: How to insert a string containing the *character in the mysql database
If the field that has the radio number is numeric(int, float, Numeric) change it to varchar, this also eliminates the problem of some number starting with zero as they are removed when they are…
-
168
votes4
answers127987
viewsA: How to make the date() function format a date in English?
Approach with strftime Use strftime() to create the full date, as this function automatically picks up the locale. As quoted by @bfavaretto, just enter the locale. strftime() in the words of the…
-
18
votes5
answers17559
viewsA: Mysqli vs PDO - which is the most recommended one to use?
The great advantage of PDO compared to mysqli is that it supports multiple databases and allows the use of parameterized names in the queries prepared while the mysqli supports only the Mysql and in…
-
5
votes3
answers34761
viewsA: Error: "You have an error in your SQL syntax"
You don’t use quotes ' simple in the names of the fields and yes crase `` When some field has the name as a reserved word like for example a product’s Decription field be called only desc, in this…
-
6
votes2
answers1352
viewsA: Always presents an error when I try to use the mysqli expression
It is necessary to pass two requirements when the 'procedural mode' is used. The first is the connection and the second the query. mysqli_query Mixed mysqli_query ( mysqli $link , string $query [,…
-
3
votes4
answers650
viewsA: Return multiple arrays using a buffer without overloading memory
If you can break the records use pagination limit/off set as quoted by @rodrigorigotti otherwise try one of the following approaches. Possible solutions Faster: Increase the memory limit of the…
-
1
votes3
answers1814
viewsA: Installation of Laravel
According to the documentation just take the version 5.3.7 php and the extension MCrypt qualified. The Laravel framework has a few system: PHP >= 5.3.7 Mcrypt PHP Extension As of PHP 5.5, some OS…
-
3
votes2
answers583
viewsA: How to save Metabox checkbox with multiple values
To send fields with multiple values it is necessary to add [] at the name. Thus grupos will be an array and then just a foreach to access all the values. echo "<input type='checkbox'…
-
3
votes4
answers2032
viewsA: Validation of forms with javascript
tipo == 'checkbox' && document.form.nome.checked !== true I believe that instead of document.form.nome would be, the variable input to be compared as nome is the type text tipo == 'checkbox'…
javascriptanswered rray 66,288 -
3
votes3
answers1762
viewsA: Php MYSQL query several tables
Use a Join to join the tables and access all the fields you need: SELECT * FROM tb_trabalhador as t INNER JOIN tb_equipamentos as e ON t.id = e.trabalhador_id INNER JOIN tb_detalhe_trabalhador as d…
-
0
votes2
answers2266
viewsA: Error: "Unexpected T_STRING" in PHP
According to this reply, the problem is in the line breaking caractres that in windows is representing as \r\nand on linux only \n I fixed it. Writing the code in Windows implied having r n as line…
-
5
votes4
answers514
viewsA: Error in mysql_fetch_object
To access the return of mysql_fetch_object() use this syntax: $row->nome_da_chave; If you want to use associative arrays use mysql_fetch_assoc(), to access the items just $row['nome_da_chave'];…
-
8
votes2
answers13056
viewsA: Changing Mysql data in PHP
Changes the sql of $sqlinsert = "Update tb_trabalhador id, Nome='$Nome', Morada='$Morada', Email='$Email' where id='$id' "; for: $sqlinsert = "Update tb_trabalhador SET Nome='$Nome' ,…
-
0
votes3
answers1343
viewsA: Empty multiple tables in a single run
I recommend using the DELETEinstead of TRUCANTE for it is not possible to give TRUNCATE in tables that have foreign keys(FK) pass an array($tables). function deleteTabela($tabelas){ $db = new PDO();…
-
5
votes3
answers3257
viewsA: Problem with Laravel date
With pure php in version 5.3 utlize createFromFormat of Datetime to convert the format of dd/mm/Y for Y-mm-dd(bank format) $data = '14/02/2014'; $data_formatada = DateTime::createFromFormat('d/m/Y',…
-
0
votes3
answers2193
viewsA: How to Mount a Dynamic Checkbox
With pure Javascript you can do it this way: php form. <html> <head> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script type="text/javascript">…
-
0
votes5
answers620
viewsA: How to select records that have a relationship with all values in a list?
Use the IN() thus various values can be passed by comma. SELECT DISTINCT cp_pessoa.id, cp_pessoa.nome FROM cp_pessoa LEFT JOIN cp_habilidade_freelancer ON (cp_habilidade_freelancer.id_freelancer =…
-
9
votes5
answers10236
viewsA: echo or print, what really is the best option?
It depends on the need, so much echo how much print sane language constructs the difference between them is that print always returns 1(true) already the echo returns nothing. print echo print('ola…
-
17
votes6
answers20131
viewsA: Difference between single and double quotes in PHP
The difference between single and double quotes is in the use. Double quotes allow: to) that variables are interpreted within it: $nome = "bob"; echo "meu nome é $nome"; b) use Use of exhaust pipes…
-
4
votes2
answers587
viewsA: Model Codeigniter Access Error
According to this topical, just leave the file in lowercase Thefuzzy0ne: If Nothing has changed then only Difference will be the Operating system (one Linux and one Windows). Windows is case…
codeigniteranswered rray 66,288 -
6
votes3
answers48813
viewsA: Receive external JSON data from PHP
Get the result by removing the true of json_decode(). json_decode($json_file); json_decode ( string $json [, bool $Assoc = false [, int $Depth = 512 [, int $options = 0 ]]] ) php.net The second…
-
3
votes2
answers14288
viewsA: How to disable a text field for editing using jQuery/Javascript?
When disabled is used in a <input type=text> for example, this field cannot be rescued by $_POST/$_GET. The appropriate is to use the attribute readonly, this ensures that the field is…