GetStartPhp

Prev charpter-> 1.Php back to index


2 Get Start MySql

2.1 install MySql

2.2 install MySql Admin UI

2.3 Connect MySql DB from PHP

<?php
$server_name = "localhost"; //where is your mysql server server
$username = "root";   // the MySql username
$password = "";      // the Mysql password

// Create a mysqli connection
$conn = new mysqli($server_name, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}else{
    echo "Connected successfully";
}
?>

php.ini

extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=oci8_19  ; Use with Oracle Database 19 Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird

2.4 php mysql examples

  1. Check mySql connection code sample: mySqlConnect
  2. Create a separate db connection files dbConfig.php file for test.php page to use.
  3. Use Php to create a new table to Test database createNewTable_test.php
  4. A From to insert new rows to database table insertRow_test.php
  5. Test page to load table row from database getData_test.php
  6. Html and Table example GetStudents

2.5 MySql Query example

  1. Create a Table

Prev chapter-> 1.Php back to index