PHP syntax error

I get the following error:

Parse error: syntax error, unexpected T_STRING in /home/www
/mariam.awardspace.info/php/pageCen.html on line 87

Code that generates the error:

$rows=mysql_num_rows($result);
print "<table border=1>\n";
print "<tr><th>Avatar</th><th>E-mail</th><th>Comments</th></tr>";
     for($i=0; $i<$rows; $i++) {
      // each call return a new record from the query, it contains both number/value and name/value pairs
        $row = mysql_fetch_array($result);

     // either use numbers 0,1,2 etc.. or the column name from the MySQL table to get the values

     if ($i%2 == 0)
         print "<tr id = 'shade'>
                <td>$row[img]</td><td><a href ='mailto:$row[email]'>$row[email]</a></td>
                <td>$row[comments]</td><td>
                <input type=button value='Disapprove' ></td></tr>";
   }

   print "</table>";

The error is under the statement if:if ($i%2 == 0)

+3
source share
2 answers

I assume that you opened the line using one quote ( ') above in your code and forgot to close it correctly. On line 87, you use single quotes ( ') again , closing this line and causing an unexpected line error.

+4
source

I think you either missed the opening { (left curly brace) for the if statement ($ i% 2 == 0), or you didn't notice the closing } for the for loop.

Try changing this:

if ($i%2 == 0)

to read the following:

if ($i%2 == 0) {

and make sure you have a closure } for the loop for.

+2
source

Source: https://habr.com/ru/post/1712890/


All Articles