-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_updatedb_control.php
55 lines (38 loc) · 1.69 KB
/
_updatedb_control.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
<?php
include 'includes/database.php';
set_time_limit(225);
function removeCtrlChars ($pString) {
for($control = 0; $control < 32; $control++) {
$pString = str_replace(chr($control), "", $pString);
}
$pString = str_replace(chr(127), "", $pString);
return $pString;
}
$DB = mysql_connect(MySQLIP, Username, Password) or die(mysql_error());
mysql_select_db(DataBase, $DB) or die(mysql_error());
mysql_query("SET NAMES 'utf8'");
$sqlquery = "select TeamID,Team from teams";
$result_id = mysql_query($sqlquery);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result_id) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $sqlquery;
die($message);
}
while ($row = mysql_fetch_assoc($result_id)) {
$value = removeCtrlChars($row['Team']);
$sqlquery = 'update teams set Team="'.$value.'" where TeamID='.$row['TeamID'] ;
$result_id2 = mysql_query($sqlquery);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result_id2) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $sqlquery;
die($message);
}
echo "TeamID=".$row['TeamID']." corrected.<br>";
}
mysql_close($DB);
echo "<br><br>==>Update completed."
?>