OOPs Tutorials
- What is OOPs
- Access Modifier
- Constructor
- Destructor
- Polymorphism
- Inheritence
- Method Overriding
- Abstract class
- Interface
- Traits
- This keyword
- static keyword
- Final keyword
- Class Constant
- Exception Handling
- Binding in php
- tostring in php
- Object Iteration
- Reflection
- Magic methods
- Namespaces
- CRUD Function
- OOPs CRUD
- CRUD Example
Important Links
CRUD Operation in php
create Database connection
File Name : config.php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Check connection
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// mysqli_close($conn);
?>
/* ********************** OR ***************** */
<?php
$host = "localhost";
$username ="root";
$password = "";
$db_name = "gmax";
$con = mysqli_connect($host,$username,$password) or die(mysqli_error());
mysqli_select_db($con,$db_name)or die(mysqli_error($con));
// mysqli_close($conn);
?>
/* ********************** OR ***************** */
<?php
define ( 'DB_HOST', 'localhost' );
define ( 'DB_USER', 'gmax' );
define ( 'DB_PASSWORD', 'gmaxpass' );
define ( 'DB_NAME', 'gmaxdb' );
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Could not connect to database server.');
mysqli_select_db($conn,DB_NAME) or die('Could not select database.');
?>
File Name :
File Name :
File Name :
File Name :
File Name :