Bonjour à tous,
Désolé le titre n'est pas trés explicite mais voilà je n'ai pas l'habitude de la POO.
LE code suivant est issu d'un livre et me renvoie l'erreur :
La ligne 11 est " private $mMysqli; "Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home.10.21/idfsyusw/www/backoffice/ajax/drag/taskslist.class.php on line 11
N'ayant jamais utilisé "private" et après quelques recherches, quelqu'un pourrait-il me dire d'où vient l'erreur. Je n'ai rien touché au code, c'est bien le code source fourni par l'auteur.
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 // load error handler and database configuration require_once ('error_handler.php'); require_once ('config.php'); // This class builds a tasks list and // performs add/delete/reorder actions on it class TasksList { // stored database connection private $mMysqli; // constructor opens database connection function __construct() { // connect to the database $this->mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE); } // destructor closes database connection public function __destruct() { $this->mMysqli->close(); } // Builds the tasks list public function BuildTasksList() { // initialize output $myList = ''; // build query $result = $this->mMysqli->query('SELECT * FROM tasks ' . 'ORDER BY order_no ASC'); // build task list as <li> elements while ($row = $result->fetch_assoc()) { $myList .= '<li id="' . htmlentities($row['id']) . '">' . htmlentities($row['description']) . '</li>'; } // return the list return $myList; } // Handles the server-side data processing public function Process($content, $action) { // perform action requested by client switch($action) { // Reorder task list case 'updateList': // retrieve update details $new_order = explode('_', $content); // update list for ($i=0; $i < count($new_order); $i++) { // escape data received from client $new_order[$i] = $this->mMysqli->real_escape_string($new_order[$i]); // update task $result = $this->mMysqli->query('UPDATE tasks SET order_no="' . $i . '" WHERE id="' . $new_order[$i] . '"'); } $updatedList = $this->BuildTasksList(); return $updatedList; break; // Add a new task case 'addNewTask': // escape input data $task = trim($this->mMysqli->real_escape_string($content)); // continue only if task name is not null if ($task) { // obtain the highest order_no $result = $this->mMysqli->query('SELECT (MAX(order_no) + 1) ' . 'AS order_no FROM tasks'); $row = $result->fetch_assoc(); // if the table is empty, order_no will be null $order = $row['order_no']; if (!$order) $order = 1; // insert the new task as the bottom of the list $result = $this->mMysqli->query ('INSERT INTO tasks (order_no, description) ' . 'VALUES ("' . $order . '", "' . $task . '")'); // return the updated tasks list $updatedList = $this->BuildTasksList(); return $updatedList; } break; // Delete task case 'delTask': // escape input data $content = trim($this->mMysqli->real_escape_string($content)); // delete the task $result = $this->mMysqli->query('DELETE FROM tasks WHERE id="' . $content . '"'); $updatedList = $this->BuildTasksList(); return $updatedList; break; } } }
Partager