Thursday, November 22, 2018

PHP setting for PHP5.3 and PHP 7 in Ubuntu



1) check php version
 php -v
 PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

 with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

Found PHP is updated from 5.3 to 7.

need to re-config  /etc/php/7.0/apache2/php.ini
 1) Change
 short_open_tag = Off
to
short_open_tag = On

2) restart server
 sudo service apache2 restart

MySQl, Error Number: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column



 MySQL version is  updatde from 5.5.36 to  5.7.24 in Ubuntu,
when I run MySQL script, the following message showed
"MySQl, Error Number: 1055  Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column"

As of MySQL 5.7.5, the default SQL mode includes ONLY_FULL_GROUP_BY which means when you are grouping rows and then selecting
something out of that groups,
you need to explicitly say which row should that selection be made from.
To turn off warning message
1. In file  /etc/mysql/my.cnf
 add
 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
 under
 [mysqld]
2. restart mysql server in
sudo service mysql restart Ubuntu


Reference:
https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql

Install the PHP module curl Ubuntu




I have following error messge for my web server in  Ubuntu after CAS server upgrade
"You need to install the PHP module curl to be able to use CAS authentication."
The following steps is to install the PHP module curl at Ubuntu:
1)  Install CURL
sudo apt-get install curl
2) restart Apache
sudo service apache2 restart
3)  Install PHP CURL
sudo apt-get install php-curl
( note: do not run sudo apt-get install php5-curl
it will return message:
"Package 'php5-curl' has no installation candidate"
In Ubuntu 16.04 default PHP version is 7.0, if you want to use different version then you need to install
 PHP package according to PHP version:

    PHP 7.2: sudo apt-get install php7.2-curl
    PHP 7.1: sudo apt-get install php7.1-curl
    PHP 7.0: sudo apt-get install php7.0-curl
    PHP 5.6: sudo apt-get install php5.6-curl
    PHP 5.5: sudo apt-get install php5.5-curl
   
    or just run sudo apt-get install php-curl
)
4) restart Apache
sudo service apache2 restart   

Another notes:
remove php 5 package
a) check php5 package
dpkg -l | grep php5
dpkg --purge --force-all php5-curl
b) remove
sudo dpkg --purge --force-all php5-curl
sudo apt-get remove php5-*
sudo apt-get purge php5-*
sudo apt-get autoremove
dpkg -l | grep php5
c) check unix server OS and version
 uname -a
Linux facts2 4.4.0-139-generic #165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
d) du -k
check space used
f) df -k
check space available
 

Wednesday, November 21, 2018

JS: reload current page and reload parent window



Current page  is opened in parent window through the link
" <a target=”_blank” href='SITASwapSection.php'> HERE</a>"
To reload current page is JS:
location.reload();

To  reload parent window
window.opener.location.reload();

More codes:
if(confirm('Are you sure to swap '+section1 + ' ' +stakeholder_name1+' with ' +section2 + ' ' +stakeholder_name2 +' in '+course+'? Click OK to proceed. Click Cancel to cancel')) {           
        $.post("../_ajaxParts/SITAAssign/SITAAssignPOST.php",  {funct:'updateSITAswap',
                                courses_offered_id1:courses_offered_id1,
                                stakeholder_id1:stakeholder_id1,
                                section1:section1,
                                assignedID1:assignedID1,
                                courses_offered_id2:courses_offered_id2,
                                stakeholder_id2:stakeholder_id2,
                                section2:section2,
                                assignedID2:assignedID2
                               
                        },  function(data){
                          formatJson(data,"div#notice", function(json){
                           
                               if(json.data['success']==1){
                               
                                 location.reload();
                                 window.opener.location.reload();

                                 formatJson('{"success":"Swap sections successfully."}', "div#notice", null);
                               }else if(json.data['success']==-1){
                                  alert("Can not swap due to different ranks");
                               }else if(json.data['success']==-2){
                                  alert("Can not swap due to empty contract");                                           
                               }else{
                                 formatJson(json.data['error'], "div#notice", null);
                               }
                            });

        });

       
}


 

Friday, November 16, 2018

Watch Halloween firework from balcony Richmond BC Oct 31 2018



I stayed at home but still have a nice view watching Halloween firework from balcony at Richmond BC on Oct 31 2018.