Php Error

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,204
Parse error: syntax error, unexpected T_SL in /var/www/shockey/admin/preupload.php on line 15

Could someone possible look this over for me. This is my first time dealing with HEREDOC syntax. I think i have an understanding of it, but I remove the space at the end of the line and it appears to break the rest of the script. (Notepad++ turns the rest gray)

I tried running it just for heck of it, Same line error shows up(Line 15)


Code:
<?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)) {  
[COLOR="Lime"]   $photo_category_list .= <<<__HTML_END  [/COLOR]
<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;  
?>


Thank for any help!!!
 

Tweakin

[H]ard|Gawd
Joined
Apr 14, 2003
Messages
1,280
From what you have pasted there, you might be getting the error due to the white space after __HTML_END;

With heredoc's in PHP, you can not have any white space (including tabs) before or after the closing heredoc tag.

Edit: Just did a quick search on your error, and came up with a post asking the same question and, funny enough, using your exact same script above! :)
http://www.phpbuilder.com/board/showthread.php?t=10333424

They resolved the issue there.
 

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,204
From what you have pasted there, you might be getting the error due to the white space after __HTML_END;

With heredoc's in PHP, you can not have any white space (including tabs) before or after the closing heredoc tag.

Edit: Just did a quick search on your error, and came up with a post asking the same question and, funny enough, using your exact same script above! :)
http://www.phpbuilder.com/board/showthread.php?t=10333424

They resolved the issue there.

Yeah. I found that also i got the same error before after fixing it. Maybe i screwed up. not sure. Anyway now i receive this.

Parse error: syntax error, unexpected $end in /var/www/shockey/admin/preupload.php on line 67

?> (end of script) progress :p

Appears i missing curly bracket
 
Top