Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am just starting PHP and I want to create a customizable menu using jquery and a PHP script that can have a variable amount of items.

Thanks to Chase for his Answer on Stack Overflow

index.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<?PHP
$script_url="http://files01.s0urc3.ismywebsite.com/jquery/nagging-menu/nagging-menu.js";
$menu_css="http://files01.s0urc3.ismywebsite.com/jquery/nagging-menu/style.css";
$links = array(
    array("url" => "http://www.something1.com", "label" => "something"),
    array("url" => "http://www.something2.com", "label" => "something2"),
    array("url" => "http://www.something3.com", "label" => "something3"),
);
include("menu.php");
?>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title></title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href=".css"/>
</head>
<body>
<?=writeMenu($links, $menu_css, $script_url)?>
</body>
</html>

menu.php:

<?
function writeMenu($links, $script_url, $menu_css){

$menu = '' $menu = ''; $menu .= ''; $menu .= '';

    foreach ($links as $item) {
        $menu .= "<li><a href=\"".$item['url']."\">".$item['label']."</a></li>";
    }

    $menu .= "</ul>";
    $menu .= "</div>";
    $menu .= "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\" charset=\"utf-8\"></script>";
    $menu .= "<script type=\"text/javascript\" src=$script_url charset=\"utf-8\"></script>";

    return $menu;
}
?>

I am getting an error when i run this. The error is:

Parse error: syntax error, unexpected T_VARIABLE in /home/s0urc3/public_html/files01/menu.php on line 5

Thanks to Chase for his Answer on Stack Overflow

share|improve this question
This question belongs on Stack Overflow. Pro Webmasters is for questions generally covering the operation of websites. – RandomBen Aug 13 '10 at 18:15
Welcome to Pro Webmasters! Your question is strictly related to programming. Please update your question on SO if you need additional help. – Tim Post Aug 13 '10 at 18:26

closed as off topic by RandomBen, Tim Post Aug 13 '10 at 18:24

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.