Paul-D Posted December 11, 2023 Share Posted December 11, 2023 (edited) I have had majour problems with my easyspace website. I beleive the servers were not updating over the weekend. I am now told that the reason for the error is on a line that should not be reached. I put a hello world and an exit at the verry top of the code. Can soneone tell me what is wrong with line 183 please [<?php if($MM > '10') {?>] After I spoke to them this morning the page says Parse error: Unclosed '{' on line 183 in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/DataInput.php on line 236 But there is no line 236. Test.txt Edited December 11, 2023 by Paul-D Quote Link to comment Share on other sites More sharing options...
Barand Posted December 11, 2023 Share Posted December 11, 2023 Give us a clue - what is the error message? Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 11, 2023 Author Share Posted December 11, 2023 As an addition, they changed my .htaccess to php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 11, 2023 Author Share Posted December 11, 2023 (edited) Error on page is Parse error: Unclosed '{' on line 183 in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/DataInput.php on line 23 Edited December 11, 2023 by Paul-D Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 11, 2023 Share Posted December 11, 2023 This would be easier if you posted the specific area of your code that is giving you this problem. Giving us a link is not the way to do it. And NOT the whole code either. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 11, 2023 Share Posted December 11, 2023 I'd start by changing all incidences of <?php} to <?php } ( ie Leave a space after <?php) Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 11, 2023 Author Share Posted December 11, 2023 One question is, if i put an exit; on line 4 why do I not get an ! am here message only? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 11, 2023 Share Posted December 11, 2023 Because it first checks the code for valid syntax before it excutes the code. Syntax errors it does find are "startup errors" Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 11, 2023 Author Share Posted December 11, 2023 Well thanks to Barrand. Leaving spaces after <?php and before ?> has made a diffrence. I have never done that before. Is this NEW to PHP8 or has it always supposed to be that way? Love to know! Quote Link to comment Share on other sites More sharing options...
Barand Posted December 11, 2023 Share Posted December 11, 2023 As far as I know, <?php always required whitespace after it. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 11, 2023 Share Posted December 11, 2023 A good way of thinking (in the coding world) is to leave a space between things to avoid any confusion as to where the previous 'thing' ends and the next 'thing' begins. So joining the php start tag and brace (<?php}) presents some confusion which you can avoid by using a simple space char Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 11, 2023 Author Share Posted December 11, 2023 Well I have done exactly as you sugest but this is still not happy. The problem is around a <select> </select> on lines 111 to 123 Error: Parse error: Unclosed '{' on line 122 in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/StatementEntry.php on line 191. I can not see any issues as there is definatly spaces here. There is .htaccess with the lines php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on phpTest.txt Quote Link to comment Share on other sites More sharing options...
kicken Posted December 11, 2023 Share Posted December 11, 2023 Line 113: <option value="<?=$PreviouseYear ?>" <?php if ($SE_YYYY_Entry == $PreviouseYear){ ?> SELECTED <?php }? > ><?=$PreviouseYear ?></option> Your closing PHP tag is malformed. Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 12, 2023 Author Share Posted December 12, 2023 That didn/t work it gave me another error Parse error: syntax error, unexpected token "?" in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/StatementEntry.php on line 113 Probably because the ending bracket was moved away from the ? SELECTED <?php }? > Quote Link to comment Share on other sites More sharing options...
Barand Posted December 12, 2023 Share Posted December 12, 2023 This section of code now works. I have highlighted the two places where I made corrections. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 12, 2023 Share Posted December 12, 2023 P.S. Your main problem is the spaghetti coding style you are using, continually moving in and out of php within the html. Try keeping them as separate as possible with php first then the html section. So something like... <?php function yearEntryOptions($current) { $CurrentMonth = date('n'); $opts = ''; for ($i = -1; $i <= 1; $i++) { $y = date('Y') + $i; $sel = $current == $y ? 'selected' : ''; $dis = ($CurrentMonth != 1 && $i == -1) || ($CurrentMonth <= 10 && $i == 1) ? 'disabled' : ''; $opts .= "<option $sel value='$y' $dis>$y</option>\n"; } return $opts; } ?> <html> <body> <select name="YYYY_Entry" style="width:60px"> <?= yearEntryOptions($SE_YYYY_Entry) ?> </select> </body> </html> 1 Quote Link to comment Share on other sites More sharing options...
Paul-D Posted December 12, 2023 Author Share Posted December 12, 2023 Thanks for that I didn't correct a <?php. PHP 8 is very strickt and takes no prisoners. I w will have to go through the rest of my code with a fine tooth comb. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.