Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
581 views
in Connecting PHP and MYSQL by (54.8k points)

Write a note PHP MySQL database connection?

Please log in or register to answer this question.

1 Answer

+1 vote
by (49.1k points)

Database Connections:

Before accessing MySQL Database, connect to Database Server machine via PHP scripting language using Mysqli_connect() Function.

Syntax:

mysqli_connect(“Server Name” , “User Name” , “Password” , “DB Name”);

This function requires four parameters to connect to database server. Database Server name, Database username, password and Database Name.

Managing Database Connections:

The below code snippet describes managing database connection methods and features. 

<?php

$servername = “localhost”;

$username = “username”;

$password = “password”;

$DBname = “SchoolDB”;

// Create connection

$conn = mysqli_connect($servemame, Susername, Spassword,$DB_name).

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...