Jump to content

This error is driving me crazy please somebody help me out


Danny620

Recommended Posts

when i run this script all i keep getting is

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\xampp\htdocs\cms\nav.php on line 35

<?php 

class Northplanet {

function Nav_Bar(){

	//Select Links From DB 
	require 'mysqli.php';

	$query = "SELECT link, link_title FROM links";  

$result = $mysqli->query($query) or die(mysqli_error($mysqli));

//Links have been found

 if($result){

echo "<ul>\n";

while ($row = $result->fetch_object()) { 

$link = $row->link;  
$title = $row->link_title;  

echo "<li><a href=\"$link\">$title</a></li>\n";

		} 

echo "</ul>\n";

}

}

?>

Try tidying the code up.

<?php 

class Northplanet {

function Nav_Bar(){

	//Select Links From DB 
	require 'mysqli.php';

	$query = "SELECT link, link_title FROM links";  
	$result = $mysqli->query($query) or die(mysqli_error($mysqli));

	//Links have been found
	if($result){
		echo "<ul>\n";

		while ($row = $result->fetch_object()) { 
			$link = $row->link;  
			$title = $row->link_title;  
			echo "<li><a href=\"$link\">$title</a></li>\n";
		} 

		echo "</ul>\n";
	}
}
?>

You appear not to be closing the class. There is a missing } at the end.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.