Tag Archives: mysql

Create a CSV file using PHP and MYSQL

csv




As we know that CSV files are one of the most used way to back-up mysql database and tables. However it is very simple to export or backup your mysql database table as CSV file if you have PhpMyAdmin interface installed on your server. Actually problem arises when we have to deal with a shared hosting. But by using PHP script, you can export complete mysql database table to csv files. Here in this post I have given you a […]

Php Interview Questions and Answers – Part 8

Php Interview Questions and Answers




Php Interview Questions and Answers – Part 8 1- Give the syntax of REVOKE commands? The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privileges b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc. We can grant rights on all database by using *.* or some specific database by database.* or a specific table by database.table_name. 2- What is the difference between CHAR and VARCHAR data types? […]

Sorting using MySQL ORDER BY Statement

Sorting using PHP MySQL ORDER BY Statement




We use Sorting using MySQL  Order by statement in a recordset.The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC You can sort on multiple columns, and you can sort different columns in different directions This query would return me the results ordered by the species in the order I need and then sort […]

Php Interview Questions and Answers – Part 6

php-interview-title




1- How can we register the variables into a session? session_register($session_var); $_SESSION[‘var’] = ‘value’; 2- What is the difference between characters �23 and x23? The first one is octal 23, the second is hex 23. With a heredoc syntax, do I get variable substitution inside the heredoc contents? Yes. 3- How can we submit form without a submit button? We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we […]

Php Interview Questions and Answers – Part 5

php3




1- How to reset/destroy a cookie ? Reset a cookie by specifying expire time in the past: Example: setcookie(‘Test’,$i,time()-3600); // already expired time Reset a cookie by specifying its name only Example: setcookie(‘Test’); 2- What types of images that PHP supports ? Using imagetypes() function to find out what types of images are supported in your PHP engine. imagetypes() – Returns the image types supported. This function returns a bit-field corresponding to the image formats supported by the version of […]

Create Database and Tables in PHP MySQL

php-mysql




As We know database holds one or multiple tables. Here in this post you will learn how create database tables in Mysql Create a Database We use the CREATE DATABASE statement to create a database in MySQL. Syntax CREATE DATABASE database_name To get PHP to execute the MYSQL statement we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. For Example The following example creates a database called “school_database”: <?php […]

Php Interview Questions and Answers – Part 3

php-interview-questions-answers




1- What is the difference between CHAR and VARCHAR data types? CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, “Hello!” will be stored as “Hello! ” in CHAR(10) column. VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, “Hello!” will be stored as “Hello!” […]

Php Interview Questions and Answers – Part 2

job-interview-question




1- Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.nHow are you?nThanks for visiting techpreparation’; print $str; ?> Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters – and n. 2- Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a […]

Mysql Full Text Search – Mysql

mysql-full-text-search




In this post you’ll learn how to build a basic full-text search engine using PHP and MySQL. What is full text search? The full-text search in mysql allows you to quick and very accurate search for single or multiple keywords from multiple columns. It does this by using an index on the columns that you want to search. There are a few limitations that you should know. Indexed columns can only be TEXT, MySQL does not by default index words […]

Mysql interview questions

mysql-question




Q 1- How to setup admin user for MYSQL ? Ans: Login as super user ‘root’ in mysql and execute the following commands. mysql> use mysql; mysql> create user ‘test’@’%’ identified by ‘test’; mysql> grant all on *.* to ‘test’@’%’ with grant option; mysql> flush privileges; Q 2- What types of privileges are there in MySQL ? Ans: There are 4 types of privileges. i). Global privileges like *.* (all hosts connecting to Mysql db server) Example: GRANT SELECT, INSERT […]