Posts Tagged with php

Displaying 1-10 of 55 results.
Resolved: Yii2 showScriptName remove index.php Not Found apache
posted by admin on June 2, 2017
I tried to remove index.php from url by many ways, but without results.
My OS is Ubuntu Linux.
Server Apache.
In web.php in config directory

<?php
$config = [
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'site/index',
'login' => 'site/login',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
]
]

Still not working
I try to created .htaccess in web direcory

RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php

Still without result
In result
404 Not Found

Not Found

The requested URL /login was not found on this server.

Apache/2.4.18 (Ubuntu) Server at tracker.dev Port 80

Please help me to resolve problemRead more
Wiki: PHP file with array with key value from MySQL table columns generator functionwiki
posted by admin on April 18, 2017

public function array_from_table_generator($table, $id, $name, $prefix = 'tbl_'){
try
{
$sql = "SELECT t.".$id.", t.".$name." FROM ".$prefix.$table. " t ORDER BY t.id DESC";
// it is select query by mysql query or mysqli or by your way
/* $results = SELECT($sql); */ //change this field by your SELECT and
// end of select query
$string = '';
$filename = '../array/'.$table.'.php';

$string .= '<?php $array = '.PHP_EOL.'array('.PHP_EOL;
foreach($results as $key => $value){
$string .= chr(9).'"' . $value[$name] . '" => ' . $value[$id] . ','.PHP_EOL;
}
$string = rtrim(trim($string),',');
$string .= PHP_EOL.');';

$handle = fopen($filename, 'w');
fwrite($handle, $string);
fclose($handle);
echo $prefix.$table . " array generated successfully!
";
}catch ( Exception $e ) {
// send error message if you can
}
}

Usage:

array_from_table_generator('device', 'id', 'name');

Result:
device.php

<?php $array =
array(
"mobile device" => 2,
"desktop" => 1
);
Read more
Resolved: PHP fopen fwrite tab tabulation
posted by admin on April 18, 2017
I have code, where I create file and write string in that file
PHP:

$string = "Some text \t any text";
$handle = fopen($filename, 'w');
fwrite($handle, $string);
fclose($handle);

Output as same as I try to create

Some text \t any text
Read more
Resolved: PHP fopen fwrite new line
posted by admin on April 18, 2017
I have code, where I create file and write string in that file
PHP:

$string = "Some text \n any text \r\n more text \n\r";
$handle = fopen($filename, 'w');
fwrite($handle, $string);
fclose($handle);

Output as same as I try create

$string = "Some text \n any text \r\n more text \n\r";

How to write text in file with new line?Read more
Wiki: PHPStorm FIX - not working hotkey CTRL + keys functionalitywiki
posted by admin on February 27, 2017
In most java-application with a GUI on Ubuntu in Russian layout is not working hotkeys, even the standard Ctrl + C and Ctrl + V. But a good man, named Michael Zheludkov wrote fix this bug, for which he had great thanks.
Installation
Clone repository in the folder ~ / fix /:

git clone https://github.com/zheludkovm/LinuxJavaFixes.git fix

Открываем конфиг приложения: or edit with GEDIT editor

nano /opt/PhpStorm/bin/phpstorm64.vmoptions

Add the following line to the fix:

-javaagent:/home/{user}/fix/build/LinuxJavaFixes-1.0.0-SNAPSHOT.jar

Replace {user} to your Ubuntu user UsernameRead more
Resolved: Ubuntu 16.04 The requested URL /phpmyadmin was not found on this server
posted by admin on February 9, 2017
After installation Ubuntu phpMyAdmin on ubuntu 16.04, I can't access to my
localhost/phpmyadmin
Error code

The requested URL /phpmyadmin was not found on this server
Read more
Resolved: JetBrains PhpStorm run terminal command line cmd from IDE space
posted by admin on February 6, 2017
I want to run terminal from cmd terminal from JetBrains PhpStorm IDE space from menu, or by keys combination or from project right click.Read more
Resolved: Composer composer self-update errors in Windows by XAMPP
posted by admin on February 1, 2017
I try to update composer and got some errors.
When I tried the command

composer self-update

Error

'composer' is not recognized as an internal or external command,
operable program or batch file.

When I tried the command

php composer self-update

Error:

Could not open input file: composer

And finally

composer.phar self-update

Error
Trying to search composer.phar in intsernetRead more
Resolved: Composer Ubuntu installation and errors
posted by admin on January 18, 2017
I am trying to install composer by that way and get some errors.
Instalation
Step 1: Ensure the Curl dependency is installed.

sudo apt-get -y install curl


Step 2: Download the Composer installer and pass it to php.

sudo curl -sS https://getcomposer.org/installer | php

My error in this step:

The program 'php' can be found in the following packages:
* php7.0-cli
* hhvm
Try: sudo apt install <selected package>
curl: (23) Failed writing body (0 != 16133)
Read more
Resolved: PHP check time 00:00:00 from datetime
posted by admin on November 21, 2016
I have datetime from MySQL db in format Y:m:d H:i:s like

2014-11-02 02:04:05
2014-11-02 00:00:00
etc ...

I want to check, if time from datetime equal "00:00:00", then return or echo only date.
Result

2014-11-02 02:04:05
2014-11-02
Read more