Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = 'user';
- $pass = 'pass';
- try {
- $db = new PDO('mysql:host=localhost;dbname=dbname', $user, $pass);
- $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- } catch(PDOException $e) {
- echo '<h1>' . $e->getMessage() . '</h1>';
- }
- ?>
- function getSnippets($snippetID, $page) {
- global $db;
- try {
- $SQL = $db->prepare('SELECT * FROM snippets WHERE id=:snippetID ORDER BY id LIMIT 10, :page');
- $SQL->setFetchMode(PDO::FETCH_ASSOC); // Set mode to fetch associative array
- $SQL->execute(array(
- ':snippetID' => $snippetID,
- ':page' => $page
- ));
- $result = $SQL->fetchALL(PDO::FETCH_ASSOC);
- return $result;
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement