Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $dsn = 'mysql:dbname=test;host=hostname';
- $user = 'username';
- $password = 'Password';
- try {
- $dbh = new PDO($dsn, $user, $password);
- echo "Connected";
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- }
- $id = 1;
- $sth = $dbh->prepare("SELECT * FROM testprepare where id = :id");
- $sth->bindParam(':id',$id, PDO::PARAM_INT);
- $sth->execute();
- $result = $sth->fetchAll();
- print_r($result);
- ?>
Add Comment
Please, Sign In to add comment