Jump to content

Unexpected $end on line 119


jaArch

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/248375-unexpected-end-on-line-119/
Share on other sites

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

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; }

?>

 

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

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.