...

View Full Version : Parse error: syntax error, unexpected '}'



wheel
03-28-2010, 04:31 AM
I cannot find out why I keep getting this error message could someone help me out with it. Thanks for any help.


)) {
echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
} else {
echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
}
echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?>
</td>
</tr>
<?php
}
?>
</table></form>
<?php
} else {
?>
<table border="0" summary="" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" summary="" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
]

MattF
03-28-2010, 04:44 AM
It's not exactly hard to spot where your problem is, if you look.



<?php
}
?>
</table></form>
<?php
} else {
?>

wheel
03-28-2010, 04:49 AM
Sorry Im new to php and I dont see what is wrong. What do I need to fix?

MattF
03-28-2010, 05:28 AM
Delete everything except for:



</table></form>


from that snippet I posted. That is assuming that what you've posted is the complete code. If it is, your HTML layout is screwed. If it isn't, post all of your code instead of selected snippets, plus the complete error message.

masterofollies
03-28-2010, 03:25 PM
<?php
if (isset($HTTP_GET_VARS['pID'])) {
echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
} else {
echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
}
echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?>
</td>
</tr>

</table></form>
<table border="0" summary="" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" summary="" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>

wincode
03-28-2010, 03:49 PM
You forgot to close the "else" brackets.

Add this line at the end of your code:


<?php } ?>

masterofollies
03-28-2010, 04:27 PM
I sure did, edited

_Aerospace_Eng_
03-28-2010, 05:09 PM
The code the OP posted is actually missing an opening if statement. Even which the bracket removed you will still get an error which means all of the code was posted. Also $HTTP_GET_VARS shouldn't be used anymore. $_GET for $HTTP_GET_VARS should be used and $_POST for $HTTP_POST_VARS should be used.

wheel
03-28-2010, 05:56 PM
Do you need me to post more code? I tried but the forum keeps telling me that it is to big. Any advice or can you tell me how much of the code that you need. Thanks for the help.

error message
Parse error: syntax error, unexpected '}' in /home/content..............categories.php on line 896

masterofollies
03-28-2010, 06:28 PM
Can you post the entire code, so we can see where line 896 is?

wheel
03-28-2010, 06:45 PM
ok I was finally able to get the whole file in a zip file. Let me know if that works. Thanks for the help again.

masterofollies
03-28-2010, 09:25 PM
Ok try this and see if it works.

wheel
03-28-2010, 09:49 PM
Hi thanks for your help with this. I am now getting the error message.

Parse error: syntax error, unexpected T_ELSE in /home/content/........./categories.php on line 896

masterofollies
03-28-2010, 11:20 PM
Ah I think I got it, there is a double else statement. Try this one.

wheel
03-29-2010, 03:42 AM
Parse error: syntax error, unexpected '}' in /home/...........categories.php on line 894

After installing the revised categories I got this error message.

Thanks for helping me out with this.

masterofollies
03-29-2010, 03:47 AM
I swear we're going to get this fixed. This fix should resolve that error. :thumbsup:

It's just a long code, and I don't have the time to read the entire thing, so we'll have to fix it step by step.

wheel
03-29-2010, 04:03 AM
Parse error: syntax error, unexpected T_ELSE in /home/...............categories.php on line 894


Here you go.

masterofollies
03-29-2010, 01:20 PM
If its rejecting an ELSE statement on every line, then it means a double else in a row, so needs an IF or an ELSEIF.

wheel
03-29-2010, 08:12 PM
Parse error: syntax error, unexpected T_ELSE in /home/.......categories.php on line 941

Thanks for working on this with me.

masterofollies
03-29-2010, 11:38 PM
It's a double else that is causing it. It's up to Fou Lu now, I have failed!

wheel
03-30-2010, 03:10 AM
Thanks for you help masterofollies. Is their anyone else that might could help me?

masterofollies
03-30-2010, 03:06 PM
Send a PM to Fou Lu. He is like the PHP Guru

xconspirisist
03-30-2010, 03:16 PM
Wheel, it seems that you do not understand the basics of PHP :/. I'll take a look at your code later on tonight, but I think you should be capable of simply checking if braces match up and if you have semicolons at the end of lines at the very least.

edit: Ugh, not fixing that.

wheel
03-31-2010, 10:16 PM
Wow xconspirisist you come in and tell me I know nothing about the code and you sit their and tell me that it must be simple braces and semicolons. Hmm you act like you are all high and mighty. :cool: I guess your not a pro like you think you are. Thanks for adding nothing to this post. :thumbsup: you are the best. Idiot

Is their anyone else out their that would like to give it a try. Thanks in advance for any positive responses.

Fou-Lu
03-31-2010, 10:24 PM
Can you post you're current code please; I can take a looksee at it. Sadly, I cannot test anything ATM until I file my taxes and buy a new computer hah hah, so I cannot make any guarentees.
Oh, its best if we can use plain text files, but I should be alright with zip since its just text files within it *looks over shoulder for boss*

wheel
03-31-2010, 10:38 PM
Hi Fou Lu

I am told that you are the man. Thanks for your help in advance. My current code is in the zip file in post #18. My current error message is Parse error: syntax error, unexpected T_ELSE in /home/.......categories.php on line 941.

Dont get in trouble by the boss :D.

Fou-Lu
03-31-2010, 11:03 PM
Line 941, right here (my format may differ from your's I ran it through an eclipse editor to try and retain indentation, but kept the same style):


if (isset($HTTP_GET_VARS['search'])) {
$search = tep_db_prepare_input($HTTP_GET_VARS['search']);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");
else {
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
}
while ($categories = tep_db_fetch_array($categories_query)) {
$categories_count++;
$rows++;



Its hard to see; that else has no prior closing to it. That block should be:


if (isset($HTTP_GET_VARS['search'])) {
$search = tep_db_prepare_input($HTTP_GET_VARS['search']);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");
} else {
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
}
while ($categories = tep_db_fetch_array($categories_query)) {
$categories_count++;
$rows++;


Also, the code is a little on the out of date side with variable handling. $HTTP_POST_VARS has been replaced with $_POST and $HTTP_GET_VARS has been replaced with $_GET. They are officially deprecated as of 5.3, and unofficially (by us PHP programmers ;)) deprecated as of 4.2. There are a few places as well that have some redundancies; I noticed some echo sprintf(....), which can simply be replaced with printf(....) (which is how I often code my stuffs).

Consider splitting some of this up; there is a lot here and I didn't have a chance to go over it all, but with a script of this size I'd suspect that there is some logic repetition with different data sets, so look at putting those into functions instead.

Try making those alterations, in specific look for that else on line 941 and be sure to add a closing curly before it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum