remove old readme
[atutor.git] / include / lib / mysql_connect.inc.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Harris Wong                                                               */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 if (AT_INCLUDE_PATH !== 'NULL') {
15         $db = @mysql_connect(DB_HOST . ':' . DB_PORT, DB_USER, DB_PASSWORD);    
16
17         if (!$db) {
18                 /* AT_ERROR_NO_DB_CONNECT */
19                 require_once(AT_INCLUDE_PATH . 'classes/ErrorHandler/ErrorHandler.class.php');
20                 $err = new ErrorHandler();
21                 trigger_error('VITAL#Unable to connect to db.', E_USER_ERROR);
22                 exit;
23         }
24         if (!@mysql_select_db(DB_NAME, $db)) {
25                 require_once(AT_INCLUDE_PATH . 'classes/ErrorHandler/ErrorHandler.class.php');
26                 $err = new ErrorHandler();
27                 trigger_error('VITAL#DB connection established, but database "'.DB_NAME.'" cannot be selected.',
28                                                 E_USER_ERROR);
29                 exit;
30         }
31         
32         //get set_utf8 config
33         $sql = 'SELECT * FROM '.TABLE_PREFIX."config WHERE name='set_utf8'";
34         $result = mysql_query($sql, $db);
35         if ($result){
36                 $row = mysql_fetch_assoc($result);
37         }
38         if ($row['value']==1){
39                 mysql_query("SET NAMES 'utf8'", $db); 
40         }       
41 }
42 ?>