jaArch Posted October 4, 2011 Share Posted October 4, 2011 I'm having trouble trying to figure out what's causing the unexpected $end error message on line 119...here's the code I have so far: <!--"StAuth10065: I certify that this material is my original work. No other person's work has been used without due acknowledgement. I have not made my work available to anyone else."--> <? if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ $_GET['rows'] = 7; ?> <html> <head> <style> body {background-color:salmon} table { border: 1px solid black; margin-right: auto; margin-left: auto;} table tr.odd, span.odd {background-color:#99CC99} table tr.even, span.even {background-color:#CCFFCC} table td {padding:5; } table td.five {background-color:#990000; color:#FFFFFF } div#form { margin-right: auto; margin-left: auto; width: 300px; text-align:center; background-color: #CCCCCC;} div#container {border: 5px ridge #990000; margin: auto auto; width: 600px; background-color:white;text-align: center} h1 {color: #CCCCCC;} a {color:#006} a:hover {text-decoration:none} </style> </head> <body> <?= '<pre>'.print_r($_POST,true).'</pre>' ?> <div id="container"> <h1>Modified Table Generator</h1> <p ><a href="<?= $_SERVER['PHP_SELF'] ?>">Generate Table using default values.</a></p> <p ><a href="<?= $_SERVER['PHP_SELF'] ?>?rows=<?= $_POST['rows'] ?>cols=10&highlight=5"> Generate Table with GET: table.php?rows=<?= $_POST['rows'] ?>&cols=10&highlight=5 </a></p> <div style=";"> <div id="form"> <form name="form1" method="post" action="table.php "> rows <select name="rows"> <option value="5" >5</option> <option value="6" >6</option> <option value="7" <? if ($_POST['rows'] == 7) echo 'selected' ?> 7 </option> <option value="8" >8</option> <option value="9" <?= ($_POST['rows'] == 9)?'selected':'notselected' ?> 9</option> <option value="10" selected>10</option> </select> cols <select name="cols"> <option value="5" >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" selected>10</option> </select> highlight <select name="highlight"> <option value="5" selected >5</option> <option value="6" >6</option> <option value="7" >7</option> <option value="8" >8</option> <option value="9" >9</option> <option value="10" >10</option> </select> <br><input type="submit" name="Submit" value="Generate Table with Post using these values"> </form> </div> </div> <body> <?php $randomnumber = rand(0,100); if ($randomnumber % 2 == 0) { $rowclass = "class=even"; $alternatingrowclass = "class=odd"; echo "<center>First number is an <span $rowclass> even</span> number</center>"; } else { $rowclass = "class=odd"; $alternatingrowclass = "class=even"; echo "<center>First number is an <span $rowclass> odd</span> number</center>"; } echo "<table>"; for ($row = 1; $row <= 10; $row ++) { if ($row %2 == 1) echo "<tr $rowclass>\n"; else echo "<tr $alternatingrowclass>\n"; for ($col = 1; $col <= 10; $col ++) { $columnclass = ($col == 5 || $col == 10) ? "class=five" : ""; echo "<td $columnclass>$randomnumber</td>\n"; $randomnumber++; } } echo "</tr>\n"; echo "</table>\n"; ?> </p> </body> </html> It seems to happen on the last line and I'm not sure why. Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/ Share on other sites More sharing options...
mikesta707 Posted October 4, 2011 Share Posted October 4, 2011 You are missing the closing brace for the following if statement: if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ I'm not sure where you mean to end this if statement's code block, but where ever it should end you need to insert the closing bracket Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275472 Share on other sites More sharing options...
wigpip Posted October 4, 2011 Share Posted October 4, 2011 at a glance it looks like you didn't close of your statement here <? if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ $_GET['rows'] = 7; ?> should be <? if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ $_GET['rows'] = 7; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275473 Share on other sites More sharing options...
Pikachu2000 Posted October 4, 2011 Share Posted October 4, 2011 What kind of function is elseof() Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275475 Share on other sites More sharing options...
AyKay47 Posted October 4, 2011 Share Posted October 4, 2011 What kind of function is elseof() i was thinking the same thing.. Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275541 Share on other sites More sharing options...
jaArch Posted October 4, 2011 Author Share Posted October 4, 2011 What kind of function is elseof() My bad. That's supposed to be elseif...minor typo Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275555 Share on other sites More sharing options...
Marooon Posted October 4, 2011 Share Posted October 4, 2011 Dear Friend , you have a lot of non-closed tags in you code for example in line 47 <option value="7" <? if ($_POST['rows'] == 7) echo 'selected' ?> 7 </option> line 50 <option value="9" <?= ($_POST['rows'] == 9)?'selected':'notselected' ?> 9</option> also you can not have two <BODY> tag in one html like you did in line30 and line 79 also in line 31 there is no '<?=' you have to put a space between the ? and the = i think you need to review your code once again for the nonclosed tags Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275558 Share on other sites More sharing options...
jaArch Posted October 4, 2011 Author Share Posted October 4, 2011 Dear Friend , you have a lot of non-closed tags in you code for example in line 47 <option value="7" <? if ($_POST['rows'] == 7) echo 'selected' ?> 7 </option> line 50 <option value="9" <?= ($_POST['rows'] == 9)?'selected':'notselected' ?> 9</option> also you can not have two <BODY> tag in one html like you did in line30 and line 79 also in line 31 there is no '<?=' you have to put a space between the ? and the = i think you need to review your code once again for the nonclosed tags Hmm, thanks! This helps alot! Should I just remove the <body> tag from line 79? Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275569 Share on other sites More sharing options...
Marooon Posted October 4, 2011 Share Posted October 4, 2011 yes, also check the code for the non-closed tag. try to use some editor like notepad++ or phpDesigner , it will help you with syntax errors Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275570 Share on other sites More sharing options...
AyKay47 Posted October 4, 2011 Share Posted October 4, 2011 word of caution when dealing with notepad++.. it's encoding is defaulted to utf-8 BOM which will include a BOM (byte order mark) in the beginning of your code... and could cause some confusion when view in browser.. will need to be changed to utf-8 no BOM.. just a heads up Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275577 Share on other sites More sharing options...
jaArch Posted October 4, 2011 Author Share Posted October 4, 2011 I'm also using Context Edit, which doesn't have syntax errors. Is notepad++ better than phpDesigner? Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275584 Share on other sites More sharing options...
Marooon Posted October 4, 2011 Share Posted October 4, 2011 i prefer using PHPDesigner , but it is not free:) it has more functions and help you a lot in formatting your code and checking it . if want free one you can use the notepad++ or any other suggested ones . good luck Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275587 Share on other sites More sharing options...
AyKay47 Posted October 4, 2011 Share Posted October 4, 2011 IMO notepad++ is one of the best freeware editors out there..at least for windows.. if not the best Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275590 Share on other sites More sharing options...
jaArch Posted October 4, 2011 Author Share Posted October 4, 2011 How do you enable debugging mode for notepad++? Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275592 Share on other sites More sharing options...
AyKay47 Posted October 5, 2011 Share Posted October 5, 2011 NP++ initially does not have debugging capabilities, however there is a plugin for NP++ that links to xDebug.. check out this link http://sourceforge.net/projects/npp-plugins/files/DBGP%20Plugin/ Quote Link to comment https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/#findComment-1275980 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.