PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
You don't have a session_start() call in that snippet?
Post your full script (in [ php ] tags) and the full error message.
I'll take a stab in the dark and guess it's a headers already sent message. In which case, a search on Google or these forums will provide your answer.
<?php
$page_title = 'View Comments about Utilities';
require_once ("main.php");
require_once ("includes/header.php");
require_once ('mysql_connect.php'); // Connect to the db.
// Number of records to show per page:
$display = 5;
// Determine how many pages there are.
if (isset($_GET['np'])) { // Already been determined.
$num_pages = $_GET['np'];
} else { // Need to determine.
// Count the number of records
$query = "SELECT COUNT(*) FROM banks2 ORDER BY name ASC";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
$num_records = $row[0];
// Calculate the number of pages.
if ($num_records > $display) { // More than 1 page.
$num_pages = ceil ($num_records/$display);
} else {
$num_pages = 1;
}
} // End of np IF.
// Determine where in the database to start returning results.
if (isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
$query = "SELECT(name) AS name, (comment) AS com, DATE_FORMAT(date, '%e %b, %y') AS date, (face) AS face FROM banks2 ORDER BY `banks2`.`date` DESC
LIMIT $start, $display";
$result = @mysql_query ($query); // Run the query.
$num = mysql_num_rows($result);
?>
<a href="view_comments.php">Banks</a> <a href="view_comments_u.php">Utilities</a> <a href="view_comments_t.php">Phone/Mob/Net</a>
<?php
if ($num > 0) { // If it ran OK, display the records.
echo "<p>You are viewing $num user comments at a time.</p>\n";
// Table header.
echo '<table align="center" border="1px" cellpadding="1" width="100%">
<tr><td align="left"><font size="2" ><b>Name of Bank</b></font></td><td align="left" ><font size="2" ><b>Comments</b></font></td><td align="left" ><font size="2" ><b>Date</b></font></td><td align="left" ><font size="2" ><b>Pos/Neg<br />/Other</b></font></td></tr>
';
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$img = null;
if ($row['face'] == 'Pos') {
$img = '<img src="includes/smile.jpg" />';
} elseif ($row['face'] == 'Neg') {
$img = '<img src="includes/sad.jpg" />';
} elseif ($row['face'] == 'Oth') {
$img = '<img src="includes/other.jpg" />';
}
// Now build the table row using the face image instead of the face field value
echo '<tr><td align="center" ><font size="2" >' . $row['name'] . '</font></td><td align="left"><font size="2" >' . $row['com'] . '</font></td><td align="center"><font size="2" >' . $row['date']. '</font></td><td align="center">' . $img .'</td></tr>';
}
echo '</table>';
mysql_free_result ($result); // Free up the resources.
} else { // If it did not run OK.
echo '<p class="error">There are none, or no more user comments.</p>';
}
mysql_close(); // Close the database connection.
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="view_comments.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
}
// If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="view_comments.php?s=' . ($start + $display) . '&np=' . $num_pages . '">Next</a>';
}
require_once ("includes/footer.php");
?>
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/arbira/public_html/tellemaustralia/view_comments.php:1) in /home/arbira/public_html/tellemaustralia/main.php on line 4
Headers already sent means that something has been sent to the browser before the session_start() call. You need to get rid of that something. Search the forums for tips on this subject.