Questions and Answers
Questions and Answers
Questions and Answers
A Controller is simply a class file that is named in a way that can be associated with a URI.
Consider this URI:
example.com/index.php/blog/
In the above example, CodeIgniter would attempt to find a controller named blog.php and load
it.
When a controller's name matches the first segment of a URI, it will be loaded.
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Hello World!';
}
}
?>
}
?>
Functions
In the above example the function name is index(). The "index" function is always
loaded by default if the second segment of the URI is empty. Another way to show
your "Hello World" message would be this:
example.com/index.php/blog/index/
The second segment of the URI determines which function in the controller
gets called.
Let's try it. Add a new function to your controller:
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Hello World!';
}
public function comments()
{
echo 'Look at this!';
}
}
?>
Question
s:1
Answers
:1
Question
s:2
how you will Create a database on the mysql server with unix shell
Answers
:2
Question
s:3
Answers
:3
Question
s:4
Answers
:4
Question
s:5
Answers
:5
Question
s:6
Answers
:6
Question
s:7
Answers
:7
Question
s:8
Answers
:8
Question
s:9
Answers
:9
Question
s : 10
Answers
: 10
Question
s : 11
Answers
: 11
Question
s : 12
Answers
: 12
Question
s : 13
How will Show all records containing the name "sonia" AND the phone
number '9876543210'
Answers
: 13
Question
s : 14
How you will Show all records not containing the name "sonia" AND the
phone number '9876543210' order by the phone_number field.
Answer :
14
Question
s : 15
How to Show all records starting with the letters 'sonia' AND the phone
number '9876543210'
Answers
: 15
mysql> SELECT * FROM tablename WHERE name like "sonia%" AND phone_number
= '9876543210';
Question
s : 16
How to show all records starting with the letters 'sonia' AND the phone
number '9876543210' limit to records 1 through 5.
Answers
: 16
mysql> SELECT * FROM tablename WHERE name like "sonia%" AND phone_number
= '9876543210' limit 1,5;
Question
s : 16
Answer :
16
Question
s : 17
Answer :
17
Question
s : 18
Answer :
18
Question
s : 19
Answers
: 19
Question
s : 20
Answer :
20
Question
s : 21
How to Creating a new user. Login as root. Switch to the MySQL db. Make
the user. Update privs.
Answer :
21
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password)
VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;
Question
s : 22
Answers
: 22
Question
s : 23
How to Change a users password from MySQL prompt. Login as root. Set
the password. Update privs.
Answer :
23
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Question
s : 24
How to Recover a MySQL root password. Stop the MySQL server process.
Start again with no grant tables. Login to MySQL as root. Set new
password. Exit MySQL and restart MySQL server.
Answer :
24
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where
User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Question
s : 25
Answer :
25
Question
s : 26
Answer :
26
Question
s : 27
How to allow the user "sonia" to connect to the server from localhost using
the password "passwd". Login as root. Switch to the MySQL db. Give privs.
Update privs.
Answers
: 27
# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to sonia@localhost identified by 'passwd';
mysql> flush privileges;
Question
s : 28
How to give user privilages for a db. Login as root. Switch to the MySQL db.
Grant privs. Update privs.
Answers
: 28
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user
(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv
) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
or
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
Question
s : 29
Answer :
29
How To update info already in a table and Delete a row(s) from a table.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv =
'Y' where [field name] = 'user';
mysql> DELETE from [table name] where [field name] = 'whatever';
Question
s : 30
Answer :
30
Question
s : 31
Answer :
31
Question
s : 32
Answer :
32
mysql> alter table [table name] change [old column name] [new column name]
varchar (50);
mysql> alter table [table name] add unique ([column name]);
Question
s : 33
Answer :
33
Question
s : 34
Answer :
34
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name]
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Question
s : 35
How to dump all databases for backup. Backup file is sql commands to
recreate all db's.
Answer :
35
Question
s : 36
Answer :
36
Question
s : 37
Answer :
37
Question
s : 38
Answer :
38
Question
s : 39
Answer :
39
Question
s : 40
Answers
: 40
Questions :
1
Answers : 1
Rasmus Lerdorf is known as the father of PHP that started development of PHP in 1994
for their own Personal Home Page (PHP) and they released PHP/FI (Forms Interpreter) version
1.0 publicly on 8 June 1995 But in 1997 two Israeli developers named Zeev Suraski and Andi
Gutmans rewrote the parser that formed the base of PHP 3 and then changed the language's
name to the PHP: Hypertext Preprocessor.
Questions :
2
What are the differences between PHP3 and PHP4 and PHP5 ? what is the current stable
version of PHP ? what advance thing in php6
Answers : 2 The current stable version of PHP is PHP 5.4.11 on 2013-01-17 as still waiting for PHP6 with
unicode handlig thing
There are lot of difference among PHP3 and PHP4 and PHP5 version of php so Difference mean
oldest version have less functionality as compare to new one like
View Answers
Questions :
3
Is variable name casesensitive ? could we start a variale with number like $4name ?
What is the difference between $name and $$name?
Answer : 3
Yes variable name casesensitive and we can not start a variable with number like $4name as A
valid variable name starts with a letter or underscore, followed by any number of letters,
numbers, or underscores.
where as $$ is variable of variable $name is variable where as $$name is variable of variable
like $name=sonia and $$name=singh so $sonia value is singh.
Questions :
4
Answers : 4 In PHP Important to notice the Limitation of HEADER() function is that header() must be called
before any actual output is send. Means must use header function before HTML or any echo
stateament
There are Number of Use of HEADER() function in php like below
1> The header() function use to sends a raw HTTP header to a client.
2> We can use herder() function for redirection of pages.
3> Use for refresh the page on given time interval automatically.
4> To send email header content like cc, bcc , reply to etc data and lot more .
View Answers
Questions :
5
Answer : 6
We can connect Mysql Database with PHP using both Procedural and Object oriented style like
below
$link = mysqli_connect("localhost", "username", "password", "dbofpcds");
$mysqli = new mysqli("localhost", "username", "password", "dbname");
and in old type of connectivity were
$link = mysql_connect("localhost", "username", "password");
mysql_select_db("database",$link);
Answer in Details
Questions :
7
In how many ways we can retrieve the data in the result set of
MySQL using PHP? What is the difference between mysql_fetch_object and
mysql_fetch_array ?
Answers : 7 we can retrieve the data in the result set of MySQL using PHP in 4 Ways
1. mysqli_fetch_row >> Get a result row as an enumerated array
2. mysqli_fetch_array >> Fetch a result row as associative and numeric array
3.mysqli_fetch_object >> Returns the current row of a result set as an object
4. mysqli_fetch_assoc >> Fetch a result row as an associative array
mysqli_fetch_object() is similar to mysqli_fetch_array(), with one difference an object is returned, instead of an array. Indirectly, that means that
we can only access the data by the field names, and not by their
offsets (numbers are illegal property names).
Answer in Details
Questions :
8
Questions :
9
Answers : 9 Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error .
Questions :
10
Answers :
10
Questions :
11
Answers :
11
What are the different tables(Engine) present in MySQL, which one is default?
Following tables (Storage Engine) we can create
1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three
files. The files have names that begin with the table name and have an extension to indicate the
file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The
index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has
commit, rollback, and crash-recovery capabilities to protect user data.)
3. Merge
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored in
memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although
HEAP remains supported for backward compatibility. )
5. BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the Berkeley DB
transactional storage engine. This storage engine typically is called BDB for short. BDB tables may
have a greater chance of surviving crashes and are also capable of COMMIT and ROLLBACK
operations on transactions)
6. EXAMPLE
7. FEDERATED (It is a storage engine that accesses data in tables of remote databases rather
than in local tables. )
8. ARCHIVE (The ARCHIVE storage engine is used for storing large amounts of data without
indexes in a very small footprint. )
9. CSV (The CSV storage engine stores data in text files using comma-separated values format.)
10. BLACKHOLE (The BLACKHOLE storage engine acts as a "black hole" that accepts data but
throws it away and does not store it. Retrievals always return an empty result)
Questions :
12
Answers :
12
Questions :
13
Answers :
13
Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.
Questions :
14
Suppose your Zend engine supports the mode <? ?> Then how can u
configure your PHP Zend engine to support <?PHP ?> mode ?
Answers :
14
In php.ini file:
set
short_open_tag=on
to make PHP support
Questions :
15
Answers :
15
Questions :
16
Answers :
16
Inserts HTML line breaks (<BR />) before all newlines in a string.
Questions :
17
Answers :
17
Questions :
18
Answers :
18
Questions :
19
What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs, servers and
operating systems?
Answers :
19
Questions :
20
Answers :
20
Questions :
21
Answers :
21
encryption
decryption
AES_ENCRYT()
AES_DECRYPT()
ENCODE()
DECODE()
DES_ENCRYPT()
DES_DECRYPT()
ENCRYPT()
Not available
MD5()
Not available
OLD_PASSWORD()
Not available
PASSWORD()
Not available
SHA() or SHA1()
Not available
Not available
UNCOMPRESSED_LENGTH()
Questions :
22
Answers :
22
Questions :
23
Answers :
23
There are lot of difference between procedure language and object oriented like below
1>Procedure language easy for new developer but complex to understand whole software as
compare to object oriented model
2>In Procedure language it is difficult to use design pattern mvc , Singleton pattern etc but in
OOP you we able to develop design pattern
3>IN OOP language we able to ree use code like Inheritance ,polymorphism etc but this type of
thing not available in procedure language on that our Fonda use COPY and PASTE .
Questions :
24
Answers :
24
Questions :
25
Questions :
26
Answer : 26 Three are three types of errors:1. Notices: These are trivial,
non-critical errors that PHP encounters while executing a script for
example, accessing a variable that has not yet been defined. By default,
such errors are not displayed to the user at all although, as you will
see, you can change this default behavior.2. Warnings: These are more serious errors for
example, attempting
to include() a file which does not exist. By default, these errors are
displayed to the user, but they do not result in script termination.3. Fatal errors: These are critical
errors for example,
instantiating an object of a non-existent class, or calling a
non-existent function. These errors cause the immediate termination of
the script, and PHP's default behavior is to display them to the user
when they take place.
Questions :
27
Answers :
27
Questions :
28
Answer : 28 Java script submit() function is used for submit form without submit button
on click call document.formname.submit()
Questions :
29
Answer : 29 there are lots of tools available for asp to PHP conversion. you can
search Google for that. the best one is available athttp://asp2php.naken.cc./
Questions :
30
Questions :
31
How can we get second of the current time using date function?
Questions :
32
Answer : 32 For convert the time zones using PHP we have to first set time zone
By using PHP function date_default_timezone_set()
If we want to set time zone of 'Europe/London' we have to call this funtion as
date_default_timezone_set('Europe/London')
so Now generate the timestamp for that particular timezone, on Sept 1st, 2012 at 8 am
$pcds = mktime(8, 0, 0, 9, 1, 2012);
Now set the other timezone like US/Eastern
date_default_timezone_set('US/Eastern');
date(DATE_RFC1123, $pcds) date(DATE_RFC1123, $pcds)
Output the date in a standard format (RFC1123)
Questions :
33
Questions :
34
Answer : 34 unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Questions :
35
Questions :
36
Answer : 36 To
To
To
To
Questions :
37
know
know
know
know
the
the
the
the
Answer : 37 By using
$_SERVER['HTTP_USER_AGENT']
variable.
Questions :
38
What is the maximum size of a file that can be uploaded using PHP
and how can we change this?
Answer : 38 By default the maximum size is 2MB. and we can change the following
setup at php.iniupload_max_filesize = 2M
Questions :
39
Questions :
40
How can we take a backup of a MySQL table and how can we restore
it. ?
Questions :
41
Answer : 41
Look for the opportunity to introduce index in the table you are
querying.
use limit keyword if you are looking for any specific number of
rows from the result set.
Questions :
42
How many ways can we get the value of current session id?
Questions :
43
How can we destroy the session, how can we unset the variable of
a session?
Questions :
44
Answer : 44 By using setcookie(name, value, expire, path, domain); function we can set the cookie in php ;
Set the cookies in past for destroy. like
setcookie("user", "sonia", time()+3600); for set the cookie
setcookie("user", "", time()-3600); for destroy or delete the cookies;
Questions :
45
How many ways we can pass the variable through the navigation
between the pages?
Answer : 45
Questions :
46
GET/QueryString
POST
Questions :
47
Questions :
48
Answer : 48 2 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
Questions :
49
Answer : 49 session_set_save_handler() sets the user-level session storage functions which are used for
storing and retrieving data associated with a session. This is most useful when a storage method
other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local
database.
Questions :
50
Questions :
51
List out some tools through which we can draw E-R diagrams for
mysql.
Questions :
52
How can I retrieve values from one database server and store them
in other database server using PHP?
Answer : 52 we can always fetch from one database and rewrite to another. here
is a nice solution of it.$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd")
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);At this point you can only fetch records from you previous
ResultSet,
i.e $res1 But you cannot execute new query in $db1, even if you
supply the link as because the link was overwritten by the new db.so at this point the following
script will fail
$res3 = mysql_query("query",$db1); //this will failSo how to solve that? take a look below.
$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);
$db2 = mysql_connect("host","user","pwd", true)
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);
So mysql_connect has another optional boolean parameter which
indicates whether a link will be created or not. as we connect to the
$db2 with this optional parameter set to 'true', so both link will
remain live.
now the following query will execute successfully.
$res3 = mysql_query("query",$db1);
Questions :
53
Answer : 53 Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Questions :
54
Answer : 54 You can maintain two separate language file for each of the
language. all the labels are putted in both language files as variables
and assign those variables in the PHP source. on runtime choose the
required language option.
Questions :
55
Answer : 55 Abstract class: abstract classes are the class where one or more
methods are abstract but not necessarily all method has to be abstract.
Abstract methods are the methods, which are declare in its class but not
define. The definition of those methods must be in its extending class.Interface: Interfaces are
one type of class where all the methods are
abstract. That means all the methods only declared but not defined. All
the methods must be define by its implemented class.
Questions :
56
Questions :
57
Questions :
58
Answer : 58 A stored procedure is a set of SQL commands that can be compiled and
stored in the server. Once this has been done, clients don't need to
keep re-issuing the entire query but can refer to the stored procedure.
This provides better overall performance because the query has to be
parsed only once, and less information needs to be sent between the
server and the client. You can also raise the conceptual level by having
libraries of functions in the server. However, stored procedures of
course do increase the load on the database server system, as more of
the work is done on the server side and less on the client (application)
side.Triggers will also be implemented. A trigger is effectively a type of
stored procedure, one that is invoked when a particular event occurs.
For example, you can install a stored procedure that is triggered each
time a record is deleted from a transaction table and that stored
procedure automatically deletes the corresponding customer from a
customer table when all his transactions are deleted.Indexes are used to find rows with specific
column values quickly.
Without an index, MySQL must begin with the first row and then read
through the entire table to find the relevant rows. The larger the
table, the more this costs. If the table has an index for the columns in
question, MySQL can quickly determine the position to seek to in the
middle of the data file without having to look at all the data. If a
table has 1,000 rows, this is at least 100 times faster than reading
sequentially. If you need to access most of the rows, it is faster to
read sequentially, because this minimizes disk seeks.
Questions :
59
Answer : 59 The following table describes the maximum length for each type of
identifier.
Identifier
Maximum Length
(bytes)
Database
64
Table
64
Column
64
Index
64
Alias
255
Questions :
60
Answer : 60 MySQL set can take zero or more values but at the maximum it can
take 64 values
Questions :
61
What are the other commands to know the structure of table using
MySQL commands except explain command?
Questions :
62
How many tables will create when we create table, what are they?
Questions :
63
Questions :
64
Questions :
65
Questions :
66
Questions :
67
Questions :
68
Answer : 68
Questions :
69
How can we find the number of rows in a result set using PHP?
How many ways we can we find the current date using MySQL?
Questions :
70
Answer : 70 External Style SheetsAdvantagesCan control styles for multiple documents at once. Classes can
be
created for use on multiple HTML element types in many documents.
Selector and grouping methods can be used to apply styles under complex
contextsDisadvantagesAn extra download is required to import style information for each
document The rendering of the document may be delayed until the external
style sheet is loaded Becomes slightly unwieldy for small quantities of
style definitionsEmbedded Style Sheets Advantages
Classes can be created for use on multiple tag types in the document.
Selector and grouping methods can be used to apply styles under complex
contexts. No additional downloads necessary to receive style information
Disadvantages
This method can not control styles for multiple documents at once
Inline Styles
Advantages
Useful for small quantities of style definitions. Can override other
style specification methods at the local level so only exceptions need
to be listed in conjunction with other style methods
Disadvantages
Does not distance style information from content (a main goal of
SGML/HTML). Can not control styles for multiple documents at once.
Author can not create or control classes of elements to control multiple
element types within the document. Selector grouping methods can not be
used to create complex element addressing scenarios
Questions :
71
Questions :
72
Answer : 72 Primary Key: A column in a table whose values uniquely identify the
rows in the table. A primary key value cannot be NULL. Unique Key: Unique Keys are used to
uniquely identify each row in the
table. There can be one and only one row for each unique key value. So
NULL can be a unique key.There can be only one primary key for a table but there can be more
than one unique for a table.
Question :
73
Answer : 73 Garbage Collection is an automated part of PHP , If the Garbage Collection process runs, it then
analyzes any files in the /tmp for any session files that have not been accessed in a certain
amount of time and physically deletes them. Garbage Collection process only runs in the default
session save directory, which is /tmp. If you opt to save your sessions in a different directory, the
Garbage Collection process will ignore it. the Garbage Collection process does not differentiate
between which sessions belong to whom when run. This is especially important note on shared
web servers. If the process is run, it deletes ALL files that have not been accessed in the
directory. There are 3 PHP.ini variables, which deal with the garbage collector: PHP ini value name
default session.gc_maxlifetime 1440 seconds or 24 minutes session.gc_probability 1
session.gc_divisor 100
Questions :
74
Answer : 74 Both of them are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.
Questions :
75
Questions :
76
Answer : 76 Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store 'romharshan', if each char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store 'romharshan', if each
char takes a byte. rest 10 bytes will be free.
Questions :
77
Questions :
78
Answer : 78 you can use LOAD DATA INFILE file_name; syntax to load data
from a text file. but you have to make sure thata) data is delimited
b) columns and data matched correctly
Questions :
79
How can we know the number of days between two given dates using
MySQL?
Questions :
80
How can we know the number of days between two given dates using PHP?
Questions :
81
How we load all classes that placed in different directory in one PHP File , means how to
do auto load classes
Answer : 81
by using spl_autoload_register('autoloader::funtion');
Like below
class autoloader
{
public static function moduleautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/modules/{$class}.php";
if (is_readable($path)) require $path;
}
public static function daoautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/dataobjects/{$class}.php";
if (is_readable($path)) require $path;
}
public static function includesautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/includes/{$class}.php";
if (is_readable($path)) require $path;
}
}
spl_autoload_register('autoloader::includesautoloader');
spl_autoload_register('autoloader::daoautoloader');
spl_autoload_register('autoloader::moduleautoloader');
Questions :
82
Questions :
83
Answers :
83
Questions :
84
Answers :
84
Questions :
85
Answers :
85
Questions :
86
Answers :
86
Questions :
87
Answers :
87
By checking the session variable exist or not while loading th page. As the session will exist longer
as till browser closes. The default behaviour for sessions is to keep a session open indefinitely and
only to expire a session when the browser is closed. This behaviour can be changed in the php.ini
file by altering the line session.cookie_lifetime = 0 to a value in seconds. If you wanted the
session to finish in 5 minutes you would set this to session.cookie_lifetime = 300 and restart your
httpd server.
Questions :
88
Answers :
88
we will need to compile PHP with the GD library of image functions for this to work. GD and PHP
may also require other libraries, depending on which image formats you want to work with.
Questions :
89
Answers :
89
Answer in Details
Questions :
90
Answers :
90
Questions :
91
Answers :
91
Questions :
92
Answers :
92
Questions :
93
Answers :
93
Questions :
94
Answers :
94
Questions :
95
Answers :
95
Questions :
96
Answers :
96
Questions :
97
Answers :
97
Questions :
98
Answers :
98
Questions :
99
Answers :
99
what is CURL?
CURL means Client URL Library
curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP,
HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. curl supports SSL certificates,
HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password
authentication (Basic, Digest, NTLM, Negotiate, kerberos), file transfer resume, proxy
tunneling and a busload of other useful tricks.
CURL allows you to connect and communicate to many different types of servers with many
different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file,
and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading
(this can also be done with PHPs ftp extension), HTTP form based upload, proxies, cookies,
and user+password authentication.
what is PDO ?
The PDO ( PHP Data Objects ) extension defines a lightweight, consistent interface for accessing
databases in PHP. if you are using the PDO API, you could switch the database server you used,
from say PgSQL to MySQL, and only need to make minor changes to your PHP code.
While PDO has its advantages, such as a clean, simple, portable API but its main disadvantage
is that it doesn't allow you to use all of the advanced features that are available in the latest
versions of MySQL server. For example, PDO does not allow you to use MySQL's support for
Multiple Statements.
Just need to use below code for connect mysql using PDO
try {
$dbh = new PDO("mysql:host=$hostname;dbname=databasename", $username, $password);
$sql = "SELECT * FROM employee";
foreach ($dbh->query($sql) as $row)
{
print $row['employee_name'] .' - '. $row['employee_age'] ;
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
Questions :
100
Answers :
100