unexpected T_VARIABLE in zelfgedefineerde functie
Parse error: syntax error, unexpected T_VARIABLE in /home/.../configs/functions.php on line 91
Code (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
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
<?php
function logPanel($panelID, $eventKey, $text, $userID = $_SESSION['userID']) {
global $mysqli;
$sql = "INSERT INTO log (
log.userID,
log.time
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($userID))."',
NOW()
)";
// Save log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
} else {
// IF success --> Get log.ID and save specific date in log_panel table
$logID = $mysqli->insert_id;
$sql = "INSERT INTO log_panel (
log_panel.logID
log_panel.eventKey,
log_panel.panelID,
log_panel.text
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($logID))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($panelID))."',
'".$mysqli->real_escape_string(htmlspecialchars($text))."'
)";
// save the panel_log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
// Log completely entered
}
}
?>
function logPanel($panelID, $eventKey, $text, $userID = $_SESSION['userID']) {
global $mysqli;
$sql = "INSERT INTO log (
log.userID,
log.time
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($userID))."',
NOW()
)";
// Save log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
} else {
// IF success --> Get log.ID and save specific date in log_panel table
$logID = $mysqli->insert_id;
$sql = "INSERT INTO log_panel (
log_panel.logID
log_panel.eventKey,
log_panel.panelID,
log_panel.text
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($logID))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($panelID))."',
'".$mysqli->real_escape_string(htmlspecialchars($text))."'
)";
// save the panel_log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
// Log completely entered
}
}
?>
Ik krijg het probleem niet gevonden, waarschijnlijk gewoon blind, zie nl geen missend ) of ' of ;
Misschien een paar regels erboven?
Kun je 5 regels ervoor ook laten zien?
Code (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
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
<?php
// Set authorisation of user Used to populate
function setAuth($eventKey, $authID) {
global $mysqli, $sql;
$sql = "INSERT INTO users_auth (
userID,
eventKey,
authID,
date
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($_SESSION['userID']))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($authID))."',
NOW()
)";
if(!$result = $mysqli->query($sql)) {
if ($mysqli->errno == 1062) {
// There is already an entry, only update if state is better';)
$sql = "UPDATE
users_auth
SET
authID = '".$mysqli->real_escape_string(htmlspecialchars($authID))."',
dateChanged = NOW()
WHERE
userID = '".$_SESSION['userID']."'
AND eventKey = '".$eventKey."'
AND authID > '".$authID."'";
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
}
}
}
// Save entry to Panel Log
function logPanel($panelID, $eventKey, $text, $userID = $_SESSION['userID']) {
global $mysqli;
$sql = "INSERT INTO log (
log.userID,
log.time
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($userID))."',
NOW()
)";
// Save log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
} else {
// IF success --> Get log.ID and save specific date in log_panel table
$logID = $mysqli->insert_id;
$sql = "INSERT INTO log_panel (
log_panel.logID
log_panel.eventKey,
log_panel.panelID,
log_panel.text
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($logID))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($panelID))."',
'".$mysqli->real_escape_string(htmlspecialchars($text))."'
)";
// save the panel_log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
// Log completely entered
}
}
?>
// Set authorisation of user Used to populate
function setAuth($eventKey, $authID) {
global $mysqli, $sql;
$sql = "INSERT INTO users_auth (
userID,
eventKey,
authID,
date
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($_SESSION['userID']))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($authID))."',
NOW()
)";
if(!$result = $mysqli->query($sql)) {
if ($mysqli->errno == 1062) {
// There is already an entry, only update if state is better';)
$sql = "UPDATE
users_auth
SET
authID = '".$mysqli->real_escape_string(htmlspecialchars($authID))."',
dateChanged = NOW()
WHERE
userID = '".$_SESSION['userID']."'
AND eventKey = '".$eventKey."'
AND authID > '".$authID."'";
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
}
}
}
// Save entry to Panel Log
function logPanel($panelID, $eventKey, $text, $userID = $_SESSION['userID']) {
global $mysqli;
$sql = "INSERT INTO log (
log.userID,
log.time
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($userID))."',
NOW()
)";
// Save log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
} else {
// IF success --> Get log.ID and save specific date in log_panel table
$logID = $mysqli->insert_id;
$sql = "INSERT INTO log_panel (
log_panel.logID
log_panel.eventKey,
log_panel.panelID,
log_panel.text
) VALUES (
'".$mysqli->real_escape_string(htmlspecialchars($logID))."',
'".$mysqli->real_escape_string(htmlspecialchars($eventKey))."',
'".$mysqli->real_escape_string(htmlspecialchars($panelID))."',
'".$mysqli->real_escape_string(htmlspecialchars($text))."'
)";
// save the panel_log entry
if(!$result = $mysqli->query($sql)) {
trigger_error('Fout in query: '.$mysqli->error);
}
// Log completely entered
}
}
?>
Edit, had twee rare returns in de functie ervoor staan, deze even weggehaald. lost het probleem niet op
Gewijzigd op 23/08/2011 11:21:40 door Martijn Thomas
function logPanel($panelID, $eventKey, $text, $userID = $_SESSION['userID']) {
Parse error: syntax error, unexpected T_VARIABLE in /home/.../configs/functions.php on line 91
Betekent onverwachte variabele in /home/...
Je mag $userID = $_SESSION['userID'] daar niet gebruiken.
Wat je wel kunt doen is $userID = NULL en dan op de eerste regel van je functie:
Mijn dank is groot!