Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = 'localhost:3306'; // Host Address
- $user = 'root'; // DataBase User
- $pass = ''; // DataBase Password
- $dbname = 'mydb2';//DataBase name
- // Connecting the DataBase
- $conn = mysqli_connect($host, $user, $pass,$dbname);
- //Checking the Connection
- if(!$conn){
- die('Could not connect: '.mysqli_connect_error());
- }
- echo 'Connected successfully<br/>';
- // Inserting data into the table
- $sql = 'INSERT INTO emp5(name,emp_salary) VALUES ("sonoo", 9000)';
- //Checking the Inserted the Data
- if(mysqli_query($conn, $sql)){
- echo "Record inserted successfully";
- }else{
- echo "Could not insert record: ". mysqli_error($conn);
- }
- //connection close
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement