Allow MySQL to Store Invalid Dates

Rishi Rathor
Updated on 28-Jan-2020 10:11:12

350 Views

After enabling the SQL MODE to ALLOW_INVALID_DATES, MySQL will also be able to store invalid dates in the table. The example is given below to understand it −mysql> Insert into order1234(ProductName, Quantity, Orderdate) values('B',500,'2015-11-31'); Query OK, 1 row affected (0.06 sec) mysql> Select * from order1234; +-------------+----------+--------------+ | ProductName | Quantity | OrderDate    | +-------------+----------+--------------+ | A           | 500      | 0000-00-00   | | B           | 500      | 2015-11-31   | +-------------+----------+--------------+ 2 rows in set (0.00 sec)We can see MySQL also inserts the invalid date in a table.

Create 301 Redirection on Nginx and Apache

Samual Sam
Updated on 28-Jan-2020 10:10:43

5K+ Views

In this article, we will learn how to redirect the URLs or Domain to another address. This can be done by using the HTTP Redirection. The URL redirection is a popular technique to point one domain address to another domain address which we can achieve on Apache and Nginx both.Redirecting to an another DomainWe might face a situation in which, we have an established web-site and we need to change the domain for the site. Here, we cannot do this by deleting the older domain since this may cause breakage and disappearance of contents on the old domain is possible ... Read More

Calculate Age in Years from Birthdate in MySQL

usharani
Updated on 28-Jan-2020 10:08:56

368 Views

We can calculate age in years from birthdate as follows −mysql> SET @dob = '1984-01-17'; Query OK, 0 rows affected (0.00 sec)This above query will pass the value’1984-01-17’ in the ‘dob’ variable. Then after applying the formula in the query below, we can get the age in years.mysql> Select Date_format( From_Days( To_Days(Curdate()) - To_Days(@dob) ), '%Y' ) + 0 AS ‘Age in years; +---------------+ | ‘Age in years’| +---------------+ |   33          | +---------------+ 1 row in set (0.00 sec)

HTML5 GeoLocation Denial Callback in Chrome

Krantik Chavan
Updated on 28-Jan-2020 10:06:05

196 Views

For timeout callback in Google Chrome, try the following code:_callback = false; function successCallback(position) {    _callback = true;    console.log('success'); } function errorCallback(error) {    _callback = true;    alert('error'); } setTimeout(function(){if(!_callback)console.log('ignored')}, 20000); navigator.geolocation.getCurrentPosition(    successCallback,    errorCallback,    {timeout: 2000} );

Override HTML5 Validation

Nancy Den
Updated on 28-Jan-2020 10:05:05

1K+ Views

To ignore HTML validation, you can remove the attribute on button click using JavaScript.Uer removeAttribute() to remove an attribute from each of the matched elements.                    First Name:                                function display(id) {             document.getElementById(id).value = document.getElementById(id).removeAttribute('required');          }          

Compute Date in MySQL Using Year, Week Number, and Day of the Week

Vrundesha Joshi
Updated on 28-Jan-2020 10:04:30

142 Views

We can compute the date as follows −mysql> SET @year=2017, @week=15, @day=4; Query OK, 0 rows affected (0.00 sec)The above query will pass the value’2017’ ,’15’, ‘4’ in ‘year’, ’week’ and ‘day’ variables respectively. Then after applying the formula in the query below, we can get the date.mysql> SELECT Str_To_Date( Concat(@year,'-',@week,'-',If(@day=7,0,@day) ), '%Y-%U-%w' ) AS Date; +--------------+ | Date         | +--------------+ | 2017-04-13   | +--------------+ 1 row in set (0.00 sec)

Keep Audio Playing While Navigating Through Pages

Samual Sam
Updated on 28-Jan-2020 10:04:22

1K+ Views

To continue loading audio to play while you are navigating through pages, try the following:Use Ajax to load content History API’s pushState() can also be used to alter URL without page reload. History.js should be used for consistent behavior across multiple browsers.The pushState() has three parameters: State object For new entry created by pushState() Title: You can pass a short title URL: New history entry's URL

Move an HTML Div in a Curved Path

Lakshmi Srinivas
Updated on 28-Jan-2020 10:03:41

377 Views

To move an HTML div in a curved path, use any of the following: CSS Transitions JavaScript (jQuery) HTML5 CanvasTry JavaScript to make it work in every browser.Use the animate() method. The animate() method performs a custom animation of a set of CSS properties.The following is the syntax:selector.animate( params, [duration, easing, callback] );Here is the description of all the parameters used by this methodparams − A map of CSS properties that the animation will move toward.duration − This is an optional parameter representing how long the animation will run.easing − This is an optional parameter representing which easing function to use for the ... Read More

dragLeave Event in HTML5 Drag and Drop

karthikeya Boyini
Updated on 28-Jan-2020 10:02:35

343 Views

To solve this issue for drag and drop event, dragLeave fires before drop sometimes:onDragOver = function(e) { e.stopPropagation() } onDrop = function(e) {    /* for drop */ }Under drop, you can set this:function drop(ev) {    event.preventDefault();    var data=event.dataTransfer.getData("Text");    event.target.appendChild(document.getElementById(data)); }

UIWebView: HTML5 Canvas and Retina Display

Vrundesha Joshi
Updated on 28-Jan-2020 10:02:02

200 Views

To place the retina size image into an HTML5 canvas, try the following code with canvas:var context = myCanvas.getContext("2d"); context.attr("width", width * window.devicePixelRatio); context.attr("height", height * window.devicePixelRatio); context.scale(window.devicePixelRatio, window.devicePixelRatio); context.drawImage(img, x, y, width, height);

Advertisements