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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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