Sunday, August 18, 2019

How to connect php to mysql use PDO

How to connect php to mysql use PDO

Tags
How to connect pdo in mysql, connec php to mysql with pdo, using pdo connect with database in php, connect database php mysqli, php connect mysql example, how to connect php to sql use pdo.
How to connect php to mysql use PDO

 If you want to connect php with mysql then please connect mysql this like.
 <?php
    $server = "mysql:host=localhost;dbname=test";
    $userName ="root";
    $password="";
    $conn = new PDO($server,$userName,$password);
    if($conn){
        echo " connect success";
    }else{
        echo "  connect don't success";
    }
 
   ?>
Calse connect SQLite or DBMS then you can this like .
$conn = new PDO("sqlite:your/database/path/izlearn.db");
you coppy url folder database at save ok.
Disconnecting when you no longer need to manipulate the database, you just need to turn $conn to null;
$conn = null;

No comments:

Post a Comment