Posts by Beraldo • 336 points
17 posts
-
1
votes1
answer641
viewsA: Date Data Recovery - php + mysql
strtotime will only convert the date to timestamp if it is in YYYY-MM-DD format. If $data is already in d/m/Y format, then the call to date is unnecessary. To better understand conversion between…
-
0
votes1
answer255
viewsA: Change all type of re-request keeping the parameters and URL via htaccess
Let your .htaccess with only this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] Then program in the index.php the routes the system will have. See this…
-
0
votes2
answers650
viewsA: How to point all pages of the site to one page?
I recommend creating a route system as shown here: http://rberaldo.com.br/urls-amigaveis-sem-htaccess-usando-slim/ Your .htaccess will have only this: RewriteEngine On RewriteCond…
-
0
votes1
answer143
viewsA: Prefer immovable/product with Session/cookies using php
If you do not want to use a database, you will need to save in another location that allows future queries, such as files or cookies. The risk of saving to cookies is that they are transferred in…
-
1
votes3
answers638
viewsA: How to run PHP in interactive mode?
To run PHP in interactive mode, just use the option -a, in this way: php -a or php.exe -a (use Windows) (as long as the php executable is in your PATH) This and all other forms of PHP execution are…
-
0
votes1
answer76
viewsA: Problems with Composer, mcrypt and Laravel on Ubuntu 14.04
The error says that the "Laravel" directory already exists. Create a project by setting another name. For example: composer create-project laravel/laravel your-project-name --prefer-dist Change…
-
1
votes1
answer74
viewsA: Inserting data into SQL
To generate a single INSERT, which inserts all records at once, you need an sql in this format: INSERT INTO tabela(numero) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10) That amounts to…
-
1
votes2
answers117
viewsA: How to return more than one property with JSON?
Just add the data in the array, like this echo json_encode(array( 'nomeUsuario' => $nome, 'outro_dado' => 'novo dado' ));
-
2
votes2
answers89
viewsA: Alternative energy in Bash
Do so: cut -d ":" -f 1 <<< "$(awk "/$fld1/ { print substr(\$0,48,10) }" /home/ficheiro.txt)" Another possibility is to use pipe, like this: awk "/$fld1/ { print substr(\$0,48,10) }"…
-
1
votes1
answer529
viewsA: connect to multiple sites with Curl
At times like this I miss threads in PHP... :( Whereas only the URL will be changed with each request, you can use the following logic: $ch = curl_init(); // todos os curl_setopt aqui, exceto a URL…
-
2
votes2
answers408
viewsA: Long Polling with mysqli does not return data
This example was I who posted on my blog. There are times many ask me how to adapt the example to use database. See how to do using PDO and Sqlite: $dbFile = 'comments.db'; $PDO = new PDO( "sqlite:"…
-
3
votes3
answers50069
viewsA: How to display all the results of a SELECT in PHP?
Correct is to use Mysqli, not Mysql. <?php $MySQLi = new MySQLi( 'servidor', 'usuario', 'senha', 'banco' ); $query = "SELECT * from clientes"; $result = $MySQLi->query($query); while($fetch =…
-
1
votes2
answers953
viewsA: How to install PHP server with separate components
PHP, starting with version 5.4, brings a native web server. There is no need to feel Apache or Nginx. See more about him here: http://rberaldo.com.br/como-usar-o-servidor-nativo-do-php-5-4/ Just…
-
1
votes1
answer1190
viewsA: Access denied edit files via SFTP on Ubuntu after upload via Wordpress
This is because your Apache is run by the user www-data and you are accessing the ftp by another user. Thus, they are different users and one is not allowed to change the file of the other. You can…
-
4
votes5
answers1698
viewsA: How can I ask the user for confirmation in a bash file?
An interesting alternative to such cases is to use the command select Something like that: select i in SIM NAO do case "$i" in "SIM") echo "continuar"; ;; "NAO") echo "parar" exit 0 ;; *) echo…
-
1
votes3
answers134
viewsA: Prevent script from following symbolic links
Instead of doing ls in $HOMEDIR, use the command find, in this way: find $HOMEDIR -maxdepth 1 ! -type l The -maxdepth 1 searches only at a directory tree level (similar to ls) the ! -type l search…
-
0
votes2
answers407
viewsA: Organize folders, subfolders and acquisitions of an array?
For each folder, you can run a scandir() to fetch your files Behold http://php.net/scandir It is also possible to do this with Directoryiterator. See…