Standard php conditional:
if (date("G") < 12) {
echo 'Good morning';
} else {
echo 'Good afternoon';
}
Shorthand…
$greeting = (date("G") < 12) ? 'Good morning' : 'Good afternoon';
echo $greeting;
(http://www.addedbytes.com/php/ternary-conditionals/)
PHP
PHP
Say for example, you have a web page you want to access some data on but the database is located on a different server. To do this you will need to add another user to the mysql.users table and specify the remote location where you are accesing from.
$ mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON database_name.* TO myUser@host_name IDENTIFIED BY 'pass' WITH GRANT OPTION;
*user ‘%’ for hostname if wanting to accept connections from all hosts.
mysql> Flush priviledges
Next, edit your /etc/mysql/my.cnf file:
Comment the bind-address
#bind-address: 127.0.0.1 //if enabled with disallow connections from a remote host.
Restart mysql:
# /etc/init.d/mysql restart
Uncategorized, mysql
mysql
Problem: When executing a python script you get the following error:
SyntaxError: Non-ASCII character ‘\xe2′ in file /usr/share/onboard/utils.py on line 17, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
The Fix:
Add
# -*- coding: utf-8 -*-
to the top of your document
Uncategorized