lis-458-ol-php/mysqli_connect.php

20 lines
898 B
PHP
Raw Normal View History

2018-02-18 01:28:11 +00:00
<?php # Script 9.2 - mysqli_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL,
// selects the database to use, and sets the encoding.
// This file will be required in many other php files that need db connection.
// Set the database access information as constants:
DEFINE ('DB_USER', 'yourusername'); // you should put your username here
DEFINE ('DB_PASSWORD', 'studentid'); // you should put your password (studentID) here
DEFINE ('DB_HOST', 'dany.simmons.edu');
DEFINE ('DB_NAME', 'databasename'); // you should put the database name here.
// Make the connection.@ will make sure the error won't be returned if there is one.
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
// Set the encoding...
mysqli_set_charset($dbc, 'utf8');
?>