-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.php
executable file
·52 lines (44 loc) · 1.53 KB
/
db.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
# Type="MYSQL"
# HTTP="true"
$hostname_selfarchive = "127.0.0.1";
$database_selfarchive = "selfarchive";
$username_selfarchive = "sherpatool";
$password_selfarchive = "password";
$selfarchive_dbconnect = new mysqli("$hostname_selfarchive", "$username_selfarchive", "$password_selfarchive", "$database_selfarchive");
if ($selfarchive_dbconnect->connect_errno) {
echo "Failed to connect to MySQL: " . $selfarchive_dbconnect->connect_error;
}
// get author name from person_id
function getAuthorName($author_id) {
global $selfarchive_dbconnect;
$query = "SELECT name FROM person WHERE id = '$author_id'";
$result = $selfarchive_dbconnect->query($query) or die($selfarchive_dbconnect->error.__LINE__);
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$author_name = $row['name'];
return $author_name;
}
}
else {
echo '[PERSON NOT FOUND]';
}
}
// function committEdit($cite_num,$cite_text) {
// global $selfarchive_dbconnect;
// //db insert
// $query = "INSERT INTO citations WHERE id = SET
// person_id = '{$clean['author_id']}',
// citation = '$citation_text',
// jtitle = '{$clean['jtitle']}',
// issn = '$issn',
// conditions = '{$clean['conditions']}',
// report_choice = '{$perm_type}',
// preprint = '{$clean['preprint']}',
// postprint = '{$clean['postprint']}',
// preprint_restrictions = '{$clean['pre_restrictions']}',
// postprint_restrictions = '{$clean['post_restrictions']}'
// ";
// if (!@$selfarchive_dbconnect->query($query)) {echo $query; die; }
// }
?>