Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
scriptingclass-phonebook/database.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (18 sloc)
695 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getDatabase() { | |
// tells php that the database lives on the same server as the php file | |
//$dbhost = "localhost"; | |
$dbhost = "develop.digitalmediauconn.org"; | |
// this is the username | |
$dbuser = "phonebk"; | |
// this is the password | |
$dbpass = "phonebk"; | |
// name of the DB that we set up together | |
$dbname = "phonebk"; | |
// this just makes a little config line for PHP to read | |
$mysql_conn_string = "mysql:host=$dbhost;dbname=$dbname"; | |
//setup a new connection using the stuff up above | |
$database = new PDO($mysql_conn_string, $dbuser, $dbpass); | |
$database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
return $database; | |
} |