Mysql Yesterday and other web programing tips

SSH commands

Export data from tar
tar -xvf "filename"
Make zip archive through ssh
zip -r /home/httpd/vhosts/
Make tar archive on ssh
tar -cvvf bak.tar /usr/public_html/
Make mysqldump through ssh (backup mysql data)
mysqldump -e --force --quick --quote-names -h localhost -u root -p DBNAME > BACKUP_FILE.sql
Restore mysql data through ssh (import mysql data)
mysql -u USER -p DBNAME < dump.sql
Takes everything from contents/ and puts it into archive.tar
tar -cf archive.tar contents/
tar czvf backup.tar.gz path/to/directory
Ownerio pakeitimas
chown host1plus:host1plus ./* -R

Failo paieška direktorijoje
find /home/host1plus/public_html/support -name "*failo_vardo*"

Teksto paieška direktorijoje
grep -irE "regexpas ko ieskai" /direktorija/

Also usefull free mysql tool (community edition)

UPDATE mc_products set `description`=replace(`description`, 'what', 'with what')
Other mysql queries examples


PHP syntax


SQL queries

UPDATE mc_products set `description`=replace(`description`, 'what', 'with what')

Delete dublicate rows
         DELETE tablename                             FROM tablename,                          
          (SELECT MAX(uid) AS dupid,COUNT(uid) AS dupcnt   FROM tablename 
           GROUP BY id,url HAVING dupcnt>1) AS dups  WHERE tablename.uid=dups.dupid;

Yesterday SELECT * FROM table WHERE time_field >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)




Enable PHP debugging using .htaccess
php_flag display_errors on
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
# enable PHP error logging
php_flag log_errors on
php_value error_log /home/path/public_html/domain/PHP_errors.log

Adding PHP mime type to JS:

AddHandler x-httpd-php5 .js




AJAX tutorials

PHP4 & PHP5 on one computer