ramzess Posted August 9, 2006 Share Posted August 9, 2006 Greetings guys!I'm stuck with it just because I simply don't know PHP. Learning. I took this code from karlcore.com (thanks to it's author), I followed the instructions, bet all I get is:Parse error: parse error, unexpected T_STRING in C:\Program Files\TSW\Apache2\htdocs\EIC\menu1.php on line 3I am working and testing this under Windows XP.Here is the code:<?php $nav_options = array( "Home" => "/index.php", "Blog" => "/blog/index.php", "News" => "/news/index.php", "Resume" => "/resume/index.php", "Past Work" => "/portfolio/index.php", "Articles" => "/articles/index.php", "Downloads" => "/programming/index.php", "Links" => "/links/index.php" ); $current_url = $_SERVER['index1.php']; print("<!-- begin menu include --> <div id=\"navigation\">\n <ul id=\"navigation\">\n"); $tabindex = 2; foreach($nav_options as $key => $val){ if($val != $current_url){ print("<li><a href=\"$val\" tabindex=\"$tabindex\">$key</a> </li>"); $tabindex++;} else{ print("<li class=\"curr_loc\">$key</li>"); } } print("</ul>"); print("</div><!-- end menu include -->"); ?>As I checked the forum prior the posting my problem in here, it seemed that most commonproblem in this case is missing semicolumn. Well here I can't see them missing. :( Thank you guys in advance. Quote Link to comment Share on other sites More sharing options...
Orio Posted August 9, 2006 Share Posted August 9, 2006 I cant see any problems except the fact there's no such thing as $_SERVER['index1.php']...Orio. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 9, 2006 Share Posted August 9, 2006 Well i get the error on line 25 which is this line:print("<li><a href=\"$val\" tabindex=\"$tabindex\">$key[/url] </li>"); It is due to the fact there is no space between $key and [/url]. Therefore, php thinks that $key is an array and thinkgs /url is an element of that array. Put a space between them and it should work. Quote Link to comment Share on other sites More sharing options...
Orio Posted August 9, 2006 Share Posted August 9, 2006 Try changing this line to:print('<li><a href="'.$val.'" tabindex="'.$tabindex.'">'.$key.'</ a></li>');(Just notice I wrote "</ a>" because the forum changes it to BBcode tags, so remove the space inside the tag).Orio. Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Well unfortunately it gives me the same error. Now I even placed original, unchanged PHP script but it does not work.Complains about the same thing. It is so bad I don't know how to make my own script yet... all I want is a vertical menu included in every page on my sitewhere menu itself resides in a single file, so if I might change something in future, I don't need to change through every singlefile. And that is what I know how to make very well. Reason I am messing with this code is that I would like the menuitem (link) become styled by CSS when the page it points to is currently open. By styling I mean changing background color ofthe active item. And this wonderful code from http://karlcore.com/programming/dynav/ seemed to be the best solution, butnow I am desperate. :(Re $_SERVER['index1.php']originally there was // define our current location $current_url = $_SERVER['PHP_SELF']; Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Or maybe, if there is another way out of this problem (not using this script) you guys could help me with that.I don't know what to do. Thank you. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 9, 2006 Share Posted August 9, 2006 Is the error still showing up on line 3 for you? Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Yes.. unfortunately... :(maybe there is some problem in php configuration (php.ini) or maybe this code I took from the address above, (where everything is explained in comments on how to make it work), is not supposed to be working on Windows system? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 9, 2006 Share Posted August 9, 2006 Well that i dont understand. With your original code i get an error on line 25. I cant figure out what could possibly cause an error in creating that array, whatever your ini settings are. I am also using windows XP anyway.The only thing i can think is that perhaps in the code in your editor, there is a character that is not showing perhaps. Try copying the original code you pasted back into notepad and save it as a php file. Then try it again. Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Here is a good example of what I am trying to achieve: http://www.asma.org/this is how I am trying to make my navigation panel work...I know how to make it work like that putting this control panel contents in every single page of my site,but what I want to do is to put it in only one file and then to be called in by php... :( Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Ok I will try... Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Wow... that is just great, you guys are great. Thanks GingerRobot!I did copy it from the site, step by step, excluding comments and everything, and it works now!well... not the way I want, but at least it generates the contents of menu and does not give me this error.now I got to unbderstand what this // define our current location$current_url = $_SERVER['PHP_SELF']; and// tabindex is set to "2" here, because my "skiplink" is set as "1"// more information on a skiplink can be found at// http://www.wac.ohio-state.edu/tutorials/section508/skipnav.htm// more information on tabindex can be found at// http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex$tabindex = 2;does. should I leave this PHP_SELF as it is, or I must change it to something?and tabindex? does it indexes my menu items for when I use TAB key on kyeboard? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 9, 2006 Share Posted August 9, 2006 [quote author=ramzess link=topic=103540.msg412434#msg412434 date=1155129923]should I leave this PHP_SELF as it is, or I must change it to something?and tabindex? does it indexes my menu items for when I use TAB key on kyeboard?[/quote]Yes. Yes. Quote Link to comment Share on other sites More sharing options...
ramzess Posted August 9, 2006 Author Share Posted August 9, 2006 Well thank you very much for being so welcome and helpful. I believe for you it is nothing for me it is my first try in PHP and making my own website! Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.