-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
83 lines (45 loc) · 1.5 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
//for each row in stories table
//get the informant, get the sid (primary key)
//select ID from digihitch_wordpress.wp_users where display_name = informant
//insert into can stories table wp_authorID (update);
$user_name = "digihitch_wp";
$password = "s7BRUt3Zdp7LwHEW";
$database = "digihitch";
$server = "localhost";
@ $db = new mysqli($server,$user_name,$password,$database);
if (mysqli_connect_errno()) {
echo 'didnt connect';
exit;
} else {
$query = "select sid,informant from can_stories";
$result = $db->query($query);
echo $result->num_rows;
for($i=0; $i < $result->num_rows; $i++) {
$row = $result->fetch_assoc();
$author = $row['informant'];
$rowKey = $row['sid'];
// echo gettype($rowKey);
$success= mysqli_select_db($db, 'digihitch_wordpress');
// echo $author;
$query = "select ID from wp_users where display_name='".$author."'";
// echo $query;
// echo "<br><br><br>";
$wpID = $db->query($query);
// var_dump($wpID);
$wpIDNumber = 0;
//get the number out of result and store it in the var
for($z=0; $z< $wpID->num_rows; $z++) {
$wpIDRow = $wpID->fetch_assoc();
$wpIDNumber = $wpIDRow['ID'];
// var_dump($wpIDNumber);
}
//switch database back
mysqli_select_db($db, 'digihitch');
$query = "update can_stories set wp_authorID=".mysqli_real_escape_string($db,$wpIDNumber)." where sid=".mysqli_real_escape_string($db,$rowKey);
// echo $query;
}
}
$result->free();
$db->close();
?>