Jump to content

Php syntax error help


jason360

Recommended Posts

Could someone please help me with this syntax error?

 

I can't figure out what is wrong...i am a beginner.  Screenshot attached.

 

Any help is appreciated.  Thanks

 

Here is the code I am having trouble with:

 

 

<?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; 

?>

 

[attachment deleted by admin]

Link to comment
Share on other sites

I guess you're familiar with the heredoc syntax? Read this.

echo <<<DELIMITER
blah blah
DELIMITER;

In your case, the delimiter is __HTML_END

 

For some reason, you have three spaces at the end of every line, but the starting and end lines of these heredoc statements cannot contain ANY whitespace after the delimiter. They must immediately be followed by a newline character.

Remove the spaces at the end of the lines every time you use those delimiters. More specifically, at lines 15, 17, 23, 34, 39, and 66.

Link to comment
Share on other sites

Place your code in tags. In the editor for the post you'll see # select your code and click it.

 

Check out: http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

 

 

 

<?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;  
?>

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.