Jump to content

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'


Recommended Posts

Hi,

 

I was wondering if somebody can help me with an error I am getting.

 

Here is my code:

 

if ($_SESSION['username']=='login') {
   if (isset($_REQUEST['file'])) {
       $fc = file_get_contents($_REQUEST['file']);
       $text = explode("<!-- EDITABLE -->",$fc);
       echo "<form method='post' action=''><textarea name='content'>$text[1]</textarea>";
       echo "<p><input type='hidden' name='file' value='".$_REQUEST['file']."' /><input name='submitUpdate' type='submit' value='Update Page'></form>";
   }
   else {
      echo "<p align='center'>
       <a href="index.html">Home Page</a><br/> //THIS IS THE LINE THAT IS GIVING THE ERROR
       <a href="contact_us.html">Contact Us</a><br/>
       <br/>
       <em>Click on the links above to edit the files.</em><br/>
      <a href="?logout">logout</a></p>";
   } 
}

 

 

This code is within php tags is that correct? As I am coding in notepad ++ and it doesn't have any colour which makes me think something is wrong.

 

If someone could help that would be brilliant! Thanks in advance :)

Since your echo uses double quotes for the primary string then you must either escape the double quotes inside, use single quotes or use heredoc.  For example, I would use single quotes for the attribute values:

Home Page

That worked wonders thank you. However there was another error in the first line of the code I posted before would it be possible to help me with that as well?

 

if ($_SESSION['username']=='login') {

 

It says undefined variable _SESSION

 

I've tried using isset but it just gave me the error:

 

Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')'

 

Hopefully you can help :)

  • 2 weeks later...
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.