Computing.Net > Forums > Web Development > syntax error, unexpected $end

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

syntax error, unexpected $end

Reply to Message Icon

Name: rsasalm
Date: October 22, 2005 at 02:41:06 Pacific
OS: Win XP
CPU/Ram: P4
Comment:

Hi all,

I am new to PHP and hope someone can help me.
I have a very simple script as below and when I run this I get the following error:

Parse error: syntax error, unexpected $end in c:\wamp\www\test\index.php on line 59
Line 59 is a blank line.
**********************************************
<?php
include("config.inc.php"); // here I connect to database and it works fine


$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 );

// Final Output
echo <<<__HTML_END

<html>
<head>
<title>Gallery View</title>
</head>
<body>
<form enctype='multipart/form-data' action='index.php' method='post' name='upload_form'>
<table width='100%' border='0' align='center' style='width: 100%;'>

<tr>
<td>
Select Product Category:
</td>
</tr>

<tr>
<td>
<select name='category'>
$photo_category_list
</select>
</td>
</tr>
<tr>
<td >
<input type='submit' VALUE="GO" />
</td>
</tr>


</table>
</form>

</body>
</html>

__HTML_END;
?>

***************************************************
I even searched for the answer on the internet and most of time the only answer I found is the some
closing braces are missing.
But as my code is very simple I don't see any such misstake.
Can someone see in my code that what else I am missing.
thanks for help
regards
/rsasalm



Sponsored Link
Ads by Google

Response Number 1
Name: rsasalm
Date: October 22, 2005 at 08:46:23 Pacific
Reply:

Hi all again,

Haven't got any response and still waiting for if someone can help in solving my problem.

The code I am using is taken from the site:

http://www.sitepoint.com/article/php-gallery-system-minutes/2

If I run the application found at the above link, it works but not mine the small one script

Any comments
thanks in advance
regards
/rsasalm


0

Response Number 2
Name: Michael J (by mjdamato)
Date: October 22, 2005 at 09:07:10 Pacific
Reply:

What version of PHP are you running your code on? The <<< are not supported priot to PHP4.

Have you tried to do any trouble shooting? It's not rocket science. Just remove/comment out small sections until you no longer get the error. Then you know where the error is occuring. You just need to be sure that you don't comment out just the beginning or end of a loop/function/etc.

In this case I would remove the entire section of Final Output. If that works, then comment out the inside of the while function. Etc., etc.

Michael J


0

Response Number 3
Name: rsasalm
Date: October 22, 2005 at 09:39:58 Pacific
Reply:

I am using PHP version : 5.0.4.
I have tested the application found
http://www.sitepoint.com/article/php-gallery-system-minutes/2

which uses the same code
while( $row = mysql_fetch_array( $result ) )
{
$photo_category_list .=<<<__HTML_END
<option
value="$row[0]">$row[1]</option>\n
__HTML_END;
}

and it works but not in my script.
I have tested with add/remove code with for trouble shooting.
if I remove the lines
$photo_category_list .=<<<__HTML_END
<option
value="$row[0]">$row[1]</option>\n
__HTML_END;


and put something else in the while loop
like echo "Hello world"
I can see that "Hello world" string apprears
in the web.
Any comments
regards
/rsasalm



0

Response Number 4
Name: Michael J (by mjdamato)
Date: October 22, 2005 at 11:13:33 Pacific
Reply:

Try changing that line to this:

$photo_category_list .= '<option
value="'.$row[0].'">'.$row[1].'</option>\n';


Michael J


0

Response Number 5
Name: rsasalm
Date: October 22, 2005 at 12:29:22 Pacific
Reply:

Thanks Micael for reply,

Now I can see that drop down list is filled with two values "family" and "friends" (see below for explanation) and which i correct.

Now I go back to my first mail.
where I have a code line
$result = mysql_query( "SELECT category_id,category_name FROM gallery_category"

where $result variable contain 2 rows as below
row[0] row[1]
(int id) (text name)
R1: 1 family
R2: 2 freinds


Now in dropdown list apprears both family and friends.
When I click on submit button "Go" (see my first mail) and do echo dropdown list values at the top of the script as below:
$cid = (int)($_GET['category']);
echo $cid;

I always get "0" value(no matter if I choose family or friends) why??
thanks for help
regards
/rsasalm


0

Related Posts

See More



Response Number 6
Name: Michael J (by mjdamato)
Date: October 22, 2005 at 14:09:13 Pacific
Reply:

I don't see int as a valid PHP operator (there is an intval)

Again you need to go back to basic trouble shooting. That first line is trying to modify the submitted value in someway (using the int). Just have it echo the posted value to see if it is coming across correctly:

echo $_GET['category'];

If that works, then try using (intval) instead of (int)

Michael J


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: syntax error, unexpected $end

syntax error in form redirect, desperate www.computing.net/answers/webdevel/syntax-error-in-form-redirect-desperate/4145.html

error in php www.computing.net/answers/webdevel/error-in-php/3595.html

,CSV file import to website | HOW? www.computing.net/answers/webdevel/csv-file-import-to-website-how/3425.html