Forum Moderators: coopster

Message Too Old, No Replies

syntax error, unexpected T ELSE

my else, if, while in a row has to be throwing it off

         

php4U

10:57 am on Mar 18, 2008 (gmt 0)

10+ Year Member



I solved the problem with the mail being sent, but now when I try to add validation to check for empty fields I get the unexpected T_ELSE (I think it might be the if, while, else combo in bold) This is the shortend version but the bottom else in bold is line 97 where php gives the error.

<?php
require_once "../include/Validator.php";

if ($HTTP_POST_VARS){
$validator = new Validator();
$validator->validateGeneral($HTTP_POST_VARS['page_no'], EDITOR_PAGE_NO);
$validator->validateGeneral($HTTP_POST_VARS['title'], EDITOR_CATEGORY_TITLE);
$validator->validateGeneral($HTTP_POST_VARS['fckeditor'], EDITOR_CONTENT);

if ( $validator->foundErrors() ){
echo '<b style="color:#C92E2A; font-size:12px;"> '. ERROR_PLEASE_INSERT .' </b> <br /><i>'.$validator->listErrors('<br>').'</i><br><br />';
}else{

require_once 'system_data.php';
$query = "select fname,email from newsletter where status='1'";
$result = mysql_query($query) or die(mysql_error());

if (0 == mysql_num_rows($result))
{
echo "<p>".SEND_EMPTY_SUBSCRIBERS_LIST."</p>";
}

else
{
if (isset($_POST['submit']))
{

while (list($full_name,$email) = mysql_fetch_row($result))
{

//////portion of code loads class and sets the email message along with sending it (NO IF ELSE STATEMENTS HERE)

}
}
}
echo "<b>".SEND_SUCCESS."</b>";
}
else
{
?>
<?php print "" . $_POST['fckeditor'] . "" ?>
<form action="<?php "" .$_SERVER['PHP_SELF']. "" ?>" method="post">

((((((((((REST OF MY FORM AND CREATES THE EDITOR INSTANCE)))))))))))

<p class="submit"><input type='submit' name='submit' value='<?php echo BUTTON_SEND ?>' class="buttons" /></p>
</form>
<?php
}
}
?>

The form submits to itself, and if there are errors I would like them to show along with the form again. General format for this should be right, but syntax isn't. I may need something near the bottom else, but I can't figure it out. Thanks!

Habtom

11:07 am on Mar 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You have three extra closing brackets:
}
}
}

php4U

10:02 pm on Mar 18, 2008 (gmt 0)

10+ Year Member



Thanks Habtom

I didn't have a whole lot of time to work with this before I had to leave today. I will have a look when I get home since I couldn't resolve it this morning. I made some changes above "SEND_SUCCESS" but no luck.

php4U

4:01 am on Mar 19, 2008 (gmt 0)

10+ Year Member



I worked with this and got errors to clear, but it skipped down through the code and sent the blank email anyway. It is not that long, but rather than posting all the code here, for now I put some basic javascript checks in place. I would like to revisit this though, just so all the validation matches.

php4U

3:05 am on Mar 20, 2008 (gmt 0)

10+ Year Member



Habtom or anyone else...would you mind if I posted the whole code here? As I mentioned in the post above the code isn't that long, and I decided that PHP really is the way to go on this.

I am really at a loss on this, and hopefully someone can help me with the exact code. Let me know, and I can post the code. Thank you.

coopster

3:52 pm on Mar 20, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Is it still a T ELSE error? If so, have you considered an editor that will show you syntax errors? A quick search over these forums will turn up plenty of options, TextPad, for instance. It's not that we don't want to see the entire code, it's just that we are trying to help you help yourself [webmasterworld.com]. For future coding, a syntax-validating editor is going to prove itself a great time-saver for you.

I would encourage you to try that first, but if you are still stuck, by all means we have plenty of extra eyes around here to help you spot the issue.

Murdoch

6:53 pm on Mar 20, 2008 (gmt 0)

10+ Year Member



I happen to like Notepad2 if you want to try that out. It highlights beginning and end brackets for you, which is nice, along with the usual tag/text coloration format.

php4U

12:31 am on Mar 21, 2008 (gmt 0)

10+ Year Member



I cleared the T ELSE error finally, but I need to work with the code to get it to stop executing after the validation takes place because it says there are errors and sends the blank mail anyway. Part of it is going in on existing code to modify it, and make it work the way I want. I am going from an existing plain text only email system to a multipart HTML/text format system. Honestly, I think that is the best way to learn is if you know how it works that way you can say "it works because of this". I never really have been a fan of posting code and saying here fix it. I'll work with this a little more tonight to see what I can come up with.

Currently I use a combo of standard notepad, and dreamweaver 8. I use Dreamweaver more for the "design" view(used back in the static HTML page days LOL)...but it does have syntax highlighting but nothing outstanding for PHP. coopster I checked out your suggestion TextPad which by the screenshots looks like it could be a big help. It looks like the parenthasis and brackets are highlighted better to make them stand out more. Murdoch I also checked out your solution Notepad2 which looks like a powerful lightweight solution that offers custom highlighting.

Thank you both for the suggestions, I will certainly check them out. I'll see what I can come up with and post if I have additional questions, thanks again!