Menu Close

Category: Web Development

Invalid datetime value in mysql 5.7

Mysql 5.7 added a validation on datetime so blank value or ‘0000-00-00 00:00:00’ are no more valid dates and it will give you an error if you try to edit/alter a column with this value from console, phpmyadmin or from your applications.
For avoid this issue, you should set every datatime column as NULLABLE, but if you have existing databases and existing applications it’s lots of work.
A workaround for this problem is edit “sql_mode” option in your code, like prestashop:
https://github.com/PrestaShop/PrestaShop/pull/4507/files

But, if you want that phpmyadmin continues to work fine, you have to edit mysql conf file and set sql_mode persistently.

View Live current mysql queries

For see from command line current execution of queries you can use:

$ mysqladmin -u bob -p -i 1 processlist

This will print the current queries on your screen every second.

  • -u The mysql user you want to execute the command as
  • -p Prompt for your password (so you don’t have to save it in a file or have the command appear in your command history)
  • i The interval in seconds.

If you want to see output like “SHOW FULL PROCESSLIST” you can attach “–verbose” to the command.

Uptime of web services

Sometime we found 99%, 99,95% etc of uptime guarantee in web services and hosting.
This is a little table of how many hours in one year we can have downtime according of uptime percents:

 

hours in one year: 8765,81277

uptime guarantee H uptime max downtime in one year
99,00% 8678,15 87,66 H
99,10% 8686,92 78,89 H
99,50% 8721,98 43,83 H
99,90% 8757,05 8,77 H
99,95% 8761,43 4,38 H
99,99% 8764,94 0,88 H

Get URL Parameters using jQuery

by jquerybyexample.net

In today’s post, you will see small piece of code but really effective and useful. That is how to get URL Parameters using jQuery. Now days every server language provide direct method to get the URL parameters but this is not straight forward with jQuery.

To implement this, I have created a function which returns value of any parameters variable.

Creare un E-Commerce con WordPress e WooCommerce

By marchettidesign.com
WordPress è un CMS dalle grandi potenzialità e negli anni si è sviluppato molto arrivando a poter realizzare le più diverse tipologie di siti. L’unica “pecca” a mio avviso era la mancanza di un plug-in per E-Commerce di alto livello: c’erano vari plug-in, come WP e-Commerce e altri, ma tutti erano difficili da utilizzare e non ben integrati con WordPress.

Dopo anni di attesa il plug-in è arrivato e si chiama WooCommerce.

WooCommerce 2.0 from WooThemes on Vimeo.

How to disable mysql fulltext stopwords?

by nivas.hr
The stopword list is a list of most used words in english language. Common words such as “some”, “little”, “let” or “then” are stopwords and do not match if present in the search string.

Basically, fulltext searching for any of the stopwords would return (almost) all the entries, so MySQL ignores those words to reduce result pollution and for efficiency.

If the word starts with stopword, that word is returned, however if your word IS stopword, you are out of luck. Here is a list of build in stopwords in MySQL 5.0/5.1. Yeah, well this is so very exciting, but whole universe DOES NOT speak and write just english.

Apache – Hide PHP Version (X-Powered-By)

by ducea.com

Applies: apache 1.3.x / apache 2.0.x Required apache module: mod-php4/mod-php5 Scope: php.ini Type: security

Description: How to hide the PHP version to remote requests. Useful: to not disclose un-needed information. As shown in Discover the web server software and version of a remote server anyone can find our valuable information from our apache server banner… This will show you how to suppress the PHP banner X-Powered-By.

Utilizzare operatore ternario per if/else in PHP

by rhadrix.net

Probabilmente avete familiarità con le istruzioni if di PHP. È molto simile alla sua controparte in molti altri linguaggi di programmazione e rappresenta uno dei concetti fondamentali della programmazione. L’istruzione if è facile da capire e facile da padroneggiare. Questo è probabilmente quello che siete abituati a leggere:

if ($eta -->= 18) {
 $messaggio = "Sei maggiorenne!";
 }
 else {
 $messaggio = "Spiacenti, non hai i requisiti!";
 }

Ma c’è un modo per costruire questo concetto e aumentare un po’ le prestazioni di $eta nel processo. Per fare questo si usa l’operatore ternario, che sarebbe una notazione abbreviata per le istruzioni if??.