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!
Moderator: General Moderators
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Sat Apr 01, 2006 12:18 pm
I don't know where this error is coming from.
"
Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/bruceg/inspired-evolution.com/includes/menu.php on line 34
"
code:
Code: Select all
<?php
$menu = <<<MENU
<ul id="navlist">
<li class="first"><a href="/About_Me.php" title="you know you want to
learn more about me">AboutMe</a></li>
<li><a href="/Skillset.php" title="I've got skillz">Skillset</a></li>
<li><a href="/Hireme.php" title="I can do wonders for your web
presence">Hire Me</a></li>
<li><a href="/Portfolio.php"
title="websites,graphics,newsletters">Portfolio</a></li>
<li><a href="/Contact.php"title="how to get in touch with me">Contact</a></li>
<li><a href="/Resume.php"title="my beautiful
resume">Résumé</a></li>
<li><a href="http://inspiredevolution.blogs.com/inspiredevolutioncom/"title="the
blog of Inspired-Evolution.com">Blog</a></li>
<li class="last"><a href="RSS.php"title="Syndication that is really
simple">RSS</a></li>
</ul>
MENU;
$lines = split("\n", $menu);
foreach ($lines as $line) {
$current = false;
preg_match('/href="([^"]+)"/', $line, $url);
if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) {
$line = str_replace('<a h', '<a id="current" h', $line);
}
echo $line."\n";
}
//belowthevariant:
foreach($linesas$line){
$current=false;
preg_match('/href="([^"]+)"/',$line,$url);
if(substr($_SERVER["REQUEST_URI"],0,5)==substr($url[1],0,5)){
$line=str_replace('ah','aid="current"h',$line);
if($_SERVER["REQUEST_URI"]==$url[1])
$line=preg_replace('|href=".*?"|','',$line);
$pagetitle=preg_replace('/<[^>]+>/','',$line);
echo$line;
}else{
echo$line."\n";
}
}
echo'<br />'.$pagetitle;
?>
thanks for any clues
baggypants303
Forum Newbie
Posts: 9 Joined: Sat Apr 01, 2006 11:04 am
Post
by baggypants303 » Sat Apr 01, 2006 12:29 pm
I ran it in Zend and got this:
Parsing error at line 2:: $menu = <<<MENU
ambivalent
Forum Contributor
Posts: 173 Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON
Post
by ambivalent » Sat Apr 01, 2006 12:43 pm
Should not be alloneword.
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Sat Apr 01, 2006 2:15 pm
what's up with line 2? I didn't think whitespacing was an issue in PHP?
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Sat Apr 01, 2006 2:24 pm
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Wed Jun 14, 2006 11:20 am
this worked before, but I am still getting an error this time, the code I now have is:
Code: Select all
<?php
$menu = <<<MENU
<ul id="navlist">
<li><a href="#" title="link to Frequently Asked Questions section">FAQ´s</a></li>
<li><a href="#" title="link to Points of View section">Points of View</a></li>
<li><a href="#" title="link to Logo section">Logo</a></li>
<li><a href="#" title="link to Process section">Process</a></li>
<li><a href="#" title="link to Tour section">Tour</a></li>
</ul>
<ul id="navlist2">
<li><a href="#" title="link to creative section">Creative</a></li>
<li><a href="#" title="link to Brand Digital section">Brand Digital</a></li>
<li><a href="#" title="link to Direct section">Direct</a></li>
<li><a href="#" title="link to Media section">Media</a></li>
<li><a href="#" title="link to Public Relations section">Public Relations</a></li>
<li><a href="#" title="link to Research Analysis section">Research & Analysis</a></li>
</ul>
END;
$lines = split("\n", $menu);
foreach ($lines as $line) {
$current = false;
preg_match('/href="([^"]+)"/', $line, $url);
if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) {
$line = str_replace('<a h', '<a id="current" h', $line);
}
echo $line."\n";
}
//belowthevariant:
foreach ($lines as $line){
$current=false;
preg_match('/href="([^"]+)"/',$line,$url);
if(substr($_SERVER["REQUEST_URI"],0,5)==substr($url[1],0,5)){
$line=str_replace('ah','aid="current"h',$line);
if($_SERVER["REQUEST_URI"]==$url[1])
$line=preg_replace('|href=".*?"|','',$line);
$pagetitle=preg_replace('/<[^>]+>/','',$line);
echo$line;
}else{
echo$line."\n";
}
}
echo'<br />'.$pagetitle;
?>
looks like the parse error is still coming from END;
Is there a way to achieve the same thing without heredoc syntax?
GM
Forum Contributor
Posts: 365 Joined: Wed Apr 26, 2006 4:19 am
Location: Italy
Post
by GM » Wed Jun 14, 2006 11:52 am
You shouldn't be using "END;" you should be using "MENU;"
Make sure there is no whitespace before the word MENU.
With heredoc syntax, you finish the string with the same word you started it with:
Code: Select all
$myString = <<<CHEESEGRATER
Hello world, I like cheese.
CHEESEGRATER;
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Wed Jun 14, 2006 1:57 pm
after googling, I found a solution to the problem and if anyone uses DW and possibly the Mac version only and gets this error to resolve it go to preferences/Code format/line break type/change to LF(unix).
works like a charm now
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Thu Jun 15, 2006 8:57 am
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
o.k, so I can get my menu to display without errors, but the CSS isn't working with the page you are on display. I am using the PHP code displayed in previous post for the menu and for the CSS:
#navcontainer ul#navlist li a#current{
border:1px solid red;
}
when I vuew source I just get this:Code: Select all
<div id="navcontainer">
<ul id="navlist">
<li><a href="#" title="link to Frequently Asked Questions section">FAQ´s</a></li>
<li><a href="#" title="link to Points of View section">Points of View</a></li>
<li><a href="#" title="link to Logo section">Logo</a></li>
<li><a href="#" title="link to Process section">Process</a></li>
<li><a href="#" title="link to Tour section">Tour</a></li>
</ul>
<ul id="navlist2">
<li><a href="#" title="link to creative section">Creative</a></li>
<li><a href="#" title="link to Brand Digital section">Brand Digital</a></li>
<li><a href="#" title="link to Direct section">Direct</a></li>
<li><a href="#" title="link to Media section">Media</a></li>
<li><a href="#" title="link to Public Relations section">Public Relations</a></li>
<li><a href="#" title="link to Research Analysis section">Research & Analysis</a></li>
</ul>
</div>
so the CSS isn't getting picked up likes it is supposed to via the PHP
I would appreciate any hints or assitance
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Thu Jun 15, 2006 3:22 pm
I have the menu and CSS working now, but there is a small issue. I want to develop my folder structure with a parent directory and child directories so a URL might look like:
http://sitename.com/parent/child1/index.php and
http://sitename.com/parent/child2/index.php
with my current intellimenu code I get <li><a id="active"> on all pages inside the parent directory (instead of one)
Is there a way to make the menu more intelligent to determine only one page when the directory is as I am wanting to do?
here is my current code:
Code: Select all
<?php
$menu = <<<MENU
<ul id="nav1">
<li><a href="/agency/faq/index.php" title="link to FAQ page">FAQ</a></li>
<li><a href="/points_of_view.php" title="link to Points of View page.">Points of View</a></li>
<li><a href="/logo.php" title="Link to Logo page">Logo</a></li>
<li><a href="/process.php" title="Link to Process page">Process</a></li>
<li><a href="/tour.php" title="Link to Tour page">Tour</a></li>
</ul>
<ul id="nav2">
<li><a href="/creative.php" title="Link to Creative page">Creative</a></li>
<li><a href="/brand_digital.php" title="Link to Brand digital page">Brand Digital</a></li>
<li><a href="/agency/direct/index.php" title="Link to Direct page">Direct</a></li>
<li><a href="/media.php" title="Lin kto Media Page">Media</a></li>
<li><a href="/public_relations.php" title="Link to Public Relations page">Public Relations</a></li>
<li><a href="/research_analysis.php" title="Link to Research and Analysis page">Research & Analysis</a></li>
</ul>
MENU;
$lines = split("\n", $menu);
foreach ($lines as $line) {
$current = false;
preg_match('/href="([^"]+)"/', $line, $url);
if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) {
$line = str_replace('<a h', '<a id="current" h', $line);
}
echo $line."\n";
}
?>
this creates what I mentioned for FAQ and Direct pages