-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_and_open.php
35 lines (24 loc) · 1.14 KB
/
access_and_open.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// A generalization of access that also opens the database.
// To be used in two places:
// As a direct replacement of
// global $opts, $event_tools_db_prefix;
// mysql_connect($opts['hn'],$opts['un'],$opts['pw']);
// @mysql_select_db($opts['db']) or die( "Unable to select database");
// At the top of phpMyEdit files to get the database open
// This is specifically needed when doing INSERT, REPLACE or UPDATE operations,
// as it sets a mote that handles migration of '' as a decimal value.
// Display pages don't need it as such.
include_once('mysql2i.class.php'); // migration step
require_once('access.php');
global $opts, $event_tools_db_prefix;
// Open the database.
// Stored handle to $opts[’dbh’] so that open version is used by phpMyEdit
$opts[`dbh`] = mysql_connect($opts['hn'],$opts['un'],$opts['pw']);
@mysql_select_db($opts['db']) or die( "Unable to select database");
// Set a local mode to handle migration of '' as a decimal value
$query="SET @@LOCAL.sql_mode = ''";
mysql_query($query);
// Debug for errors
if (mysql_errno() != 0) print "<p>Error setting mode: ".mysql_errno() . ": " . mysql_error() . "</p>";
?>