“PHP Check Connection ke Database” Kode Jawaban

cara memeriksa apakah php terhubung ke database

<?php
$con = new mysqli("host","username","password","database");
echo $con ? 'connected' : 'not connected';
?>
Happy Hippopotamus

Koneksi Basis Data di PHP

<?php

$hostName = 'localhost';
$userNmame = 'root';
$password = '';
$dbname = 'topproduct';
$db_name = "mysql:host=$hostName;dbname=$dbname";
$conn = new PDO($db_name,$userNmame,$password);

if(!$conn){
    echo 'Error database connection';    
}
Homely Hamerkop

PHP Check Connection ke Database

<?php
$servername = "localhost";
$username = "username";
$password = "password";

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

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

Jawaban yang mirip dengan “PHP Check Connection ke Database”

Pertanyaan yang mirip dengan “PHP Check Connection ke Database”

Lebih banyak jawaban terkait untuk “PHP Check Connection ke Database” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya