//this is my connection.php
<?php
$pdo = new PDO('mysql:host=localhost;dbname=test;', 'root');
$pdo->exec("SET CHARACTER SET utf8");
?>
//this is my class.php
<?php
include 'connection.php';
$stmt = $pdo->prepare(query here); //wrong part
?>
problem: Error undefined $pdo, what is the right way in doing this? But when i transfer the code from the connection.php to class.php it works fine.