JPPPP
JPPPP
{ if (den==0.0)
else
return (num/den);
double x,y,z;
try
{
x = 12.5;
y = 0.0;
z=divide(x,y);
catch (ArithmeticException e)
System.out.println(e.getMessage());
}
//use of throw statement
int x,y,z;
try
{ x = 12; y = 0;
z = x/y;
System.out.println(x+"/"+y+"=" + z);
catch (ArithmeticException e)
System.out.println("Start of main()");
try
divide();
catch (ArithmeticException e)
}
}}
for(int j = 1 j <= 5 j++) { } System.out.println("\tFrom Thread : j ="+j) ; System. out. println("Exit from B");
}
class ThreadTest
new A().start();
new B().start();
new C().start();
12.2 Use of yield(), stop(), and sleep() methods
try sleep(1000);
catch (Exception e)
class ThreadMethods
threadA.start();
threadB.start();
System.out.println("Start thread C)
threadC.start();
<html>
<head>
<title>File Handling</title>
</head>
<body>
<?php
10.9
);
?>
<?php
// Opening a file for appending the data $myFile "pk.txt"; $fp = fopen($myFile,'a'); if($fp = false)
{
o close
2>
exit();
fclose($fp);
<?php
$myFile = "pk.txt";
$fp = fopen($myFile,'r');
if($fp = false)
$fsize = filesize($myFile)
</body>
</html>
Example:
<html>
<head>
<title>Create a Database</title>
</head>
<body>
<?php
// Create connection
$con-mysqli_connect("localhost","root","");
/ Check connection /
if (mysqli_connect_errno())
else
// Create database
if (mysqli_query($con,$sql))
else
// Close connection
mysqli_close($con);
?>
</body>
</html>
Example:
<html>
<head>
<title>Create a Table</title>
</head>
<body>
<?php
// Create connection
$con=mysqli_connect("localhost","root","","BCA");
// Check connection
if (mysqli_connect_errno())
1 else
8.6
fune
SEL
data
1
// Create table $sql="CREATE TABLE STUDENT (FirstName CHAR(30), LastName CHAR(30), Age INT)";
Exa
else
// Close connection
mysqli_close($con);
?>
</body>
</html>
Example:
<html>
<head>
</head>
<body>
<?php
// Create connection
if (mysqli_connect_errno())
else
Be
mysqli_query($con, "INSERT INTO STUDENT (FirstName, LastName, Age) VALUES ('RAJ', 'KUMAR',35)");
mysqli_query($con, "INSERT INTO STUDENT (FirstName, LastName, Age) VALUES ('PREM', 'KAUR',31)");
echo "<br>Records have been successfully inserted";
// Close connection
mysqli_close($con);
?>
</body>
</html>
<html>
<head>
<title>Selecting Records from Database Table</title>
</head>
<body>
<?php
// Create connection
$con-mysqli_connect("localhost","root","", "BCA");
// Check connection
if (mysqli_connect_errno())
else
}
echo "Database Connection successfully build";
ata
ise
oa
// Select records from the table $result = mysqli_query($con, "SELECT * FROM STUDENT");
while($row = mysqli_fetch_array($result))
echo "<br>";
// Close connection
mysqli_close($con);
?>
</body>
</html>
Example:
<html>
<head>
</head>
<body>
<?php
// Create connection
// Check connection
if (mysqli_connect_errno())
else
mysqli_query($con, "DELETE FROM STUDENT"); echo "<br>Records have been successfully deleted";
// Close connection
mysqli_close($con);
?>
</body>
</html>
</head>
<center>
</center>
<tr>
<td>
<p>
<label for="firstName">First Name:</label> <!-- To add space -->
</p>
</td>
</tr>
<tr>
can
<td>
<P>
<label for="lastName">Last Name:</label> <!-- To add space -->
</p>
</td>
</tr>
Form
Ad>
<p>
<label for="age">Age:</label>
- To add space -->
</td>
</tr>
<tr>
<td align="center">
</td>
</tr>
</table>
</form>
</body>
</html>
<head>
<title>Form Handler</title>
</head>
<body>
<?php
// Create connection
$con=mysqli_connect("localhost","root","", "BCA");
// Check connection
if($con = false)
// close connection
mysqli_close($con);
<body>
</html>
Check connection
if (mysqli_connect_errno())
<?php
php
<html>
<head>
</head>
<body>
<center>
<h3>Record Form</h3>
</center>
<tr>
<td>
<p>
<label for="firstName">First Name:</label>
Integrating PHP ar
input type="subn
</p>
</td>
</table>
</tr>
</form>
<tr>
@php
<td>
// close conne
<p>
mysqli close
<label for="lastName">Last Name:</label> <!-- To add space -->
</body>
</html>
</p>
After the
4
</td>
</tr>
<tr>
<td>
<p>
<label for="age">Age:</label>
<!- To add space-> <input type="text"
name="st_age" id="age" value="<?php echo $fetchRow['Age]>>>
</p>
</td>
</tr>
SH
<tr>
<td align="center">
</td>
</tr>
</table>
</form>
<?php
// close connection
mysqli_close($con);
?>
</body>
</html>