swiftarrow Posted November 20, 2007 Share Posted November 20, 2007 Hi all, I'm new here. I've learned C, C++, and am just starting to learn PHP, but this really has be stumped. Error Message: Parse error: syntax error, unexpected T_STRING, expecting '(' in G:\Server\www\medicine4tibet\links.config.php on line 2 Code: [pre] <h4 class="hidden">Site Navigation</h4> <ul> <?php require('../links.config.php'); foreach( $links as $filename => $nicename ) { //spit out a bunch of formatted links as: <li><a href="?item=filename.php" class="toplink">Nicename</a></li> echo "<li><a href='?item=$filename.php'>$nicename</a></li>\n"; } ?> </ul> [/pre] Contents of ../links.config.php: [pre]<?php /* This array holds the key to the website. All the pages have their Filename and their "Nice Name" $links[filename] = "Nice Name"; */ $links[index] = "Home"; ?>[/pre] It seems like the require function is throwing the error, but include does the same thing. My server is using php5, apache2. Any Ideas? I'm sure this one is simple, but it really has me stumped.. Thanks... Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted November 20, 2007 Share Posted November 20, 2007 I would change echo "<li><a href='?item=$filename.php'>$nicename[/url]</li>\n"; to echo "<li><a href='?item=$filename.php'>{$nicename['url']}</li>\n"; Quote Link to comment Share on other sites More sharing options...
swiftarrow Posted November 20, 2007 Author Share Posted November 20, 2007 Thank you for your reply, I'm having trouble figuring this editor out... THat was supposed to be preformatted text, but it doesnt allow the end anchor tag!!! it keeps replacing it with the url bbcode... so in my code that is not [ / u r l ] but < / a >... And if you know how to get it out through the editor properly.... please let me know Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 20, 2007 Share Posted November 20, 2007 To avoid this from happening, use the around your code. Ken Quote Link to comment Share on other sites More sharing options...
swiftarrow Posted November 20, 2007 Author Share Posted November 20, 2007 Ok, thanks. So I'll post it all again: Error: Parse error: syntax error, unexpected T_STRING, expecting '(' in G:\Server\www\medicine4tibet\links.config.php on line 2 Code: <h4 class="hidden">Site Navigation</h4> <ul> <?php require('../links.config.php'); foreach( $links as $filename => $nicename ) { //spit out a bunch of formatted links as: <li><a href="?item=filename.php" class="toplink">Nicename</a></li> echo "<li><a href='?item=$filename.php'>$nicename</a></li>\n"; } ?> </ul> and the contents of the required file: <?php /* This array holds the key to the website. All the pages have their Filename and their "Nice Name" If a page is added, it's details just have to be added below. The array should be declared as: $links[filename] = "Nice Name"; */ //$links = array ("index" = "Home"); $links[index] = "Home"; ?> I hope this is clearer.... Any ideas? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 20, 2007 Share Posted November 20, 2007 Keep this in links.config.php and check <?php $links = array("index" => "Home", "contact" => "Contact Us"); ?> Quote Link to comment Share on other sites More sharing options...
swiftarrow Posted November 20, 2007 Author Share Posted November 20, 2007 n~ link=topic=168390.msg742514#msg742514 date=1195534239] Keep this in links.config.php and check <?php $links = array("index" => "Home", "contact" => "Contact Us"); ?> I tried it just now, but it didnt help. Same problem. Thanks, but Anything else? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 20, 2007 Share Posted November 20, 2007 I don't know why it is not working for you for me it is working first file freaks.php <h4 class="hidden">Site Navigation</h4> <?php require('freaks2.php'); foreach( $links as $filename => $nicename ) { echo "<li><a href='?item=$filename.php'>$nicename</a></li>\n"; } ?> Second file freaks2.php <?php $links = array("index" => "Home", "contact" => "Contact Us"); ?> Save them both in the same folder and check... Quote Link to comment Share on other sites More sharing options...
swiftarrow Posted November 20, 2007 Author Share Posted November 20, 2007 Thank you so much for your time... I dont know why, but it's working... so I'll keep my files in the same folder until I cant anymore... Thanks again... 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.