Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

PHP database example to connect, get data from MySQL

<?php
$driver = 'mysql';
$database = "dbname=CODINGGROUND";
$dsn = "$driver:host=localhost;$database";

$username = 'root';
$password = 'root';

try {
   $conn = new PDO($dsn, $username, $password);
   echo "Database CODINGGROUND Connected";
}catch(PDOException $e){
   echo $e->getMessage();
}
$sql = 'SELECT  * FROM users';
$stmt = $conn->prepare($sql);
$stmt->execute();

while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
  foreach($row as $value)
  {
    echo sprintf("%s", $value);
  }
  echo "\n";
}
?>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.