Jump to content

[SOLVED] Parse Error


swiftarrow

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/78025-solved-parse-error/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/78025-solved-parse-error/#findComment-394923
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/78025-solved-parse-error/#findComment-394927
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/78025-solved-parse-error/#findComment-394939
Share on other sites

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.