Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8015397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:14:53+00:00 2026-06-04T20:14:53+00:00

I am getting a syntax error for this PHP code syntax error, unexpected T_STRING

  • 0

I am getting a syntax error for this PHP code

syntax error, unexpected T_STRING

It says line 2, which is the include line:

<?php  
  include 'config.inc.php';  
  
  // initialization  
  $photo_upload_fields = '';  
  $counter = 1;  
  
  // If we want more fields, then use, preupload.php?number_of_fields=20  
  $number_of_fields = (isset($_GET['number_of_fields'])) ?  
    (int)($_GET['number_of_fields']) : 5;  
  
  // Firstly Lets build the Category List  
  $result = mysql_query('SELECT category_id,category_name FROM gallery_category');  
  while($row = mysql_fetch_array($result)) {  
    $photo_category_list .= <<<__HTML_END

<option value="$row[0]">$row[1]</option>\n  
__HTML_END;  
  }  
  mysql_free_result( $result );    
  
  // Lets build the Image Uploading fields  
  while($counter <= $number_of_fields) {  
    $photo_upload_fields .= <<<__HTML_END  
<tr><td>  
  Photo {$counter}:  
  <input name="photo_filename[]"  
type="file" />  
</td></tr>  
<tr><td>  
  Caption:  
  <textarea name="photo_caption[]" cols="30"  
    rows="1"></textarea>  
</td></tr>  
__HTML_END;  
    $counter++;  
  }  
  
  // Final Output  
  echo <<<__HTML_END  
<html>  
<head>  
<title>Lets upload Photos</title>  
</head>  
<body>  
<form enctype="multipart/form-data"  
  action="upload.php" method="post"  
  name="upload_form">  
  <table width="90%" border="0"  
    align="center" style="width: 90%;">  
    <tr><td>  
      Select Category  
      <select name="category">  
      $photo_category_list  
      </select>  
    </td></tr>  
    <! - Insert the image fields here -->  
    $photo_upload_fields  
    <tr><td>  
      <input type="submit" name="submit"  
        value="Add Photos" />  
    </td></tr>  
  </table>  
</form>  
</body>  
</html>  
__HTML_END;  
?>

My include file looks like this:

<?php  
  $mysql_link = mysql_connect("localhost","user","password");  
  mysql_select_db("db_name") or die("Could not select database");  
  $images_dir = "photos";  
?> 

Solution:

I had invisible unicode characters hidden in the code which caused the PHP parser to complain of the above syntax error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:14:54+00:00Added an answer on June 4, 2026 at 8:14 pm

    You have multiple spaces at the start and the end of your HEREDOC syntax variables; this leads to problems. Remove the spaces after

    <<<__HTML_END
    

    and after

    __HTML_END;
    

    and your code should be working.

    See also this thread where I found the answer: http://board.phpbuilder.com/board/showthread.php?t=10333424

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im getting this error: Parse error: syntax error, unexpected T_ECHO in /home/labvc/public_html/AT/site/getimages.php on line
I am getting this error : Parse error: syntax error, unexpected T_OBJECT_OPERATOR in wp-content/themes/phil/page.php
I'm getting this error: PHP Parse error: syntax error, unexpected T_VARIABLE in /var/www/vhosts/... on
I'm getting a syntax error on this PHP code: <snip> $last = (isset($_GET['last']) &&
I am getting Parse error: syntax error, unexpected ',' in /xxx/login.php on line 28
i am using this code <a onclick=javascript:var t=setInterval(GetUpdates(5,ajaxResult),300);>GetUpdates</a> but getting the syntax error
I am getting an error Incorrect syntax near ',' for this query on line
I keep getting a syntax error Parse error: syntax error, unexpected '{' in contact_form.php
I'm getting this syntax error and I know it's PHP 101, but I wouldn't
I'm getting the below error on my server: Parse error: syntax error, unexpected T_STRING,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.