Datenbankabfrage für die Startseite (General)
Hallo!
Das gepostete Script habe ich wie angegeben verändert:
<?php // static database settings (copy'n'paste from config/db_settings.php) $mlfdb['host'] = 'localhost'; $mlfdb['user'] = 'forum'; $mlfdb['password'] = 'strenggeheim'; $mlfdb['database'] = 'forum'; // initialise the global variables $mlfReturn = false; $mlfOutput = ''; /** * reads the latest entries from the mlf2 database * * The number of entries is defined in the query (LIMIT x). * * @param array $db * @param bool $debug (optional) * @return bool false * @return array */ function readLatestForumEntries($db, $debug = false) { // initialise the variable to return the output $r = array(); // connecting to the database $connid = @mysqli_connect($db['host'], $db['user'], $db['password'], $db['database']); // no connection (error) if (!$connid) return false; // define the query @mysqli_set_charset($connid, "utf8"); $query = "SELECT ft.id, -- the id of the entry itself ft.tid, -- the id of the thread (for threaded view) DATE_FORMAT(ft.time + INTERVAL 1 HOUR, '%d.%m.%Y %H:%i:%s') AS posting_time, -- date format must be adapted to the language settings if((ft.user_id > 0), ud.user_name, ft.name) AS name, -- user name from the forum table or the users table (if available) ft.subject FROM mlf2_forum_table AS ft LEFT JOIN mlf2_userdata_table AS ud ON ud.user_id = ft.user_id -- accession 0: everybody, 1: only for registered users, 2: moderators and admins only -- leave out, if there are no categories in your forum WHERE ft.category IN(SELECT id FROM mlf2_category_table WHERE accession = 0) ORDER BY ft.time DESC -- latest entries as first LIMIT 10"; /* limit the output to the latest 10 entries */ /* debugging output */ if ($debug === true) { echo '<h3>the query string</h3>'; echo '<pre>'. print_r($query, true) .'</pre>'; } $result = mysqli_query($connid, $query); // debugging output if ($debug === true) { echo '<h3>the return value of <code>mysqli_query()</code></h3>'; echo '<pre>'. print_r($result, true) .'</pre>'; } if ($result === false) return false; while ($row = mysqli_fetch_assoc($result)) { $r[] = $row; } mysqli_free_result($result); mysqli_close($connid); return $r; } $mlfOutput = '<section id="mlfLatestEntries">'; $mlfOutput .= '<h2>Latest entries in the forum</h2>'; $mlfReturn = readLatestForumEntries($mlfdb); //$mlfReturn = readLatestForumEntries($mlfdb, true); // for debugging purposes // if $mlfReturn is an array, build the list of the entries, otherwise display a "no entries" message if (is_array($mlfReturn) === true) { $mlfOutput .= '<ul>'; foreach ($mlfReturn as $row) { $mlfOutput .= '<li>'; // URL has to be adapted to threaded-posting-view (nested listing) if needed $mlfOutput .= '<a href="localhost/mlf/index.php?id='. htmlspecialchars($row['id']) .'">'. htmlspecialchars($row['subject']) .'</a> - '. htmlspecialchars($row['name']) .', '. htmlspecialchars($row['posting_time']); $mlfOutput .= '</li>'; } $mlfOutput .= '</ul>'; } else { $mlfOutput .= '<p class="mlfErrorMessage">No entries found.</p>'; } $mlfOutput .= '</section>'; echo $mlfOutput; ?>
-----------------------------------------------------------------------------------
In Zeile 43 musste ich die Kommentierung verändern
In Zeile 75 ( } else { ) bekomme ich die Fehlermeldung:
Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\start.php on line 75
Viele Grüße
Jürgen