NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

IGNOU BCA MCA Students - VIVA Question Answer for PHP PART III

IGNOU BCA MCA Students - VIVA Question Answer for PHP

PHP Selected Question Answer - PART III


1.  How to create a session? How to set a value in session ? How to Remove data from a session?
Create session : session_start();
Set value into session : $_SESSION['USER_ID']=1;
Remove data from a session : unset($_SESSION['USER_ID'];

2.  what types of loops exist in php?
for,while,do while and foreach (NB: You should learn its usage)

3.  How to create a mysql connection?
mysql_connect(servername,username,password);

4.  How to select a database?
mysql_select_db($db_name);

5.  How to execute an sql query? How to fetch its result ?
$my_qry = mysql_query("SELECT * FROM `users` WHERE `u_id`='1'; "); 
$result = mysql_fetch_array($my_qry);
echo $result['First_name'];

6.  Write a program using while loop
$my_qry = mysql_query("SELECT * FROM `users` WHERE `u_id`='1'; "); 
while($result = mysql_fetch_array($my_qry))
{
echo $result['First_name'.]."<br/>";
}

7.  How we can retrieve the data in the result set of MySQL using PHP?
o    1. mysql_fetch_row
o    2. mysql_fetch_array
o    3. mysql_fetch_object
o    4. mysql_fetch_assoc

8.  What is the use of explode() function ?
Syntax : array explode ( string $delimiter , string $string [, int $limit ] ); 
This function breaks a string into an array. Each of the array elements is a substring of string formed by splitting it on boundaries formed by the string delimiter.

9.  What is the difference between explode() and split() functions?
Split function splits string into array by regular expression. Explode splits a string into array by string.

10.               What is the use of mysql_real_escape_string() function?
It is used to escapes special characters in a string for use in an SQL statement

11.               Write down the code for save an uploaded file in php.

if ($_FILES["file"]["error"] == 0)
{
move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
 
}

No comments:

Post a Comment