Month: July 2021

  • Connection Close in Php mysql

    Connection Close in Php mysql

    When the script ends then automatically connection will be closed. To close the connection before, use the following: MySQLi Object-Oriented: $conn->close(); MySQLi Procedural: mysqli_close($conn); PDO: $conn = null;

  • PHP connect to DB

    PHP connect to DB

    Example (MySQLi procedural) mysqli_connect function is used for connection string which has 3 parameters and mysqli_connect_error function is used to display particular MySQL error. <?php$servername = “localhost”;$username = “root”;$password = “”; // Create connection$conn = mysqli_connect($servername, $username, $password); // Check connectionif (!$conn) {  die(“Connection failed: ” . mysqli_connect_error());}echo “Connected successfully”;?> Example (MySQLi Object-Oriented) <?php$servername = “localhost”;$username…

  • PHP connect to DB

    PHP connect to DB

    PHP work with a MySQL database using MySQLi (procedural), MySQLi (object-oriented) and PDO (PHP Data Objects) Difference between MySQLi and PDO PDO will work on 12 different database systems, whereas MySQLi will only work with MySQL databases. Open a Connection to MySQL To access data in the MySQL database, first of all we need to…

  • MySQL data type

    MySQL data type

    Data type specifies the particular type of data used with their possible value and the way of that values to be stored. Different datatype with their size and value are listed below: Data Type Maximum Size Explanation CHAR(size) Maximum size of 255 characters. A fixed-length string between 1 and 255 characters in length. Defining a…