
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
1K+ Views
Let us create a custom function to validate date in MySQL −mysql> set global log_bin_trust_function_creators=1; Query OK, 0 rows affected (0.03 sec) mysql> delimiter // mysql> create function isValidDate(actualDate varchar(255)) returns int -> begin -> declare flag int; -> if (select length(date(actualDate)) IS NOT NULL ) then ... Read More

AmitDiwan
510 Views
The text inside a tag inside class="text" inside with class="main" can be obtained with the following code −Example$html = nodeValue)); }OutputThis will produce the following output −string ‘This is text 1’ (length=14) string ‘This is text 2' (length=14)

AmitDiwan
494 Views
Set the column as BOOLEAN to display 0 and 1 values. Let us create a table −mysql> create table DemoTable2035 -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> isMarried boolean, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected ... Read More

AmitDiwan
1K+ Views
To declare a variable, use DECLARE in a MySQL stored procedure. Let us first create a table −mysql> create table DemoTable2034 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentAge int -> ); Query OK, 0 rows affected (0.49 ... Read More

AmitDiwan
2K+ Views
HTTP URLs can be used to behave like local files, with the help of PHP wrappers. The contents from a URL can be fetched through the file_get_contents() and it can be echoed. or read using the readfile function.Below is a sample code to do the same −$file = file_get_contents('http://example.com/'); echo ... Read More

AmitDiwan
172 Views
The below line of code can be used to display the header that the PHP code received via a browser −orExample$headers = getallheaders(); foreach($headers as $key=>$val){ echo $key . ': ' . $val . ''; }OutputThis will produce the following output −Host: www.websitename.com Content-Length: 180 Cache-Control: max-age=0 Origin: http://www.websitename.com ... Read More

AmitDiwan
4K+ Views
For dynamic SQL query in a stored procedure, use the concept of PREPARE STATEMENT. Let us first create a table −mysql> create table DemoTable2033 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (1.61 sec)Insert ... Read More

AmitDiwan
2K+ Views
The array_map function can be used to get the length and the max function can be used to get the length of the longest string.Below is a code sample for the same −$max_len = max(array_map('strlen', $array));Example Live Demo$array = array("a", "Ab", "abcd", "abcdfegh", "achn"); $max_len = max(array_map('strlen', $array)); echo $max_len;OutputThis will ... Read More

AmitDiwan
867 Views
Two variables can’t be explicitly returned, they can be put in a list/array data structure and returned.Example Live Demofunction factors( $n ) { // An empty array is declared $fact = array(); // Loop through it for ( $i = 1; $i < $n; $i++) { ... Read More

AmitDiwan
340 Views
To detect the existence of a table, use the concept of INFORMATION_SCHEMA.TABLES. Following is the syntax −select table_name from information_schema.tables where table_schema=database() and table_name=yourTableName;To understand the above syntax, let us create a table −mysql> create table DemoTable2032 -> ( -> ClientId int, -> ClientName varchar(20), -> ... Read More