Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 28th, 2005, 07:05 PM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parse error: parse error, unexpected $end

Can anyone pleas help me. I keep getting this error

Parse error: parse error, unexpected $end

when i try to run some php script and i cant seem to find a solution.

Please help. My code is shown below.

<?php
include 'config.inc.php';

// initialization
$photo_upload_fields = '';
$counter = 1;
$photo_category_list = '';

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

?>

  #2 (permalink)  
Old December 1st, 2005, 07:44 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

This errors happens because:
You either left ; in your PHP lines.
Or you not nested conditionals { and } properly.

Now, please revise your PHP code.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Support Indian students' finances http://scholarship.mediasworks.com/
  #3 (permalink)  
Old December 8th, 2006, 09:09 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check to see that an errant single or double quote hasn't escaped a semi-colon.

  #4 (permalink)  
Old January 12th, 2007, 12:21 PM
Registered User
 
Join Date: Jan 2007
Location: McMinnville, Oregon, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had this problem when I upgraded to PHP 5.2. The problem was caused by my used of the <? tag instead of <?php. I found the solution here http://www.mydigitallife.info/2006/0...nexpected-end/

In php.ini set
short_open_tag = On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
parse error, unexpected T_IF ajit_kunte BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 May 6th, 2005 09:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.