2

My first post on this brilliant website asking for some help with my first complicated php script that basically connects to a mysql db, queries data from an sqltable and displays it on a website.

Today, I got this error :=on Line 258 of my code :

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/path/public_html/advanced_bans.php on line 258

I could fix other syntax errors, but I'm not even sure if this one is actually a syntax error. Here's the code : Line 2 (line 258 in the entire code) has the error

1 foreach( $result as $row ) { #modified

2 echo "<tr id='<?php echo $row['name']; ?>'".( ( $start % 2 ) == 0 ? " bgcolor=\"#FFFFFF\"" : " bgcolor=\"#E5E5E5\"" ) .">\n";

3 echo "<td style=\"text-align:center\">";
4 //echo ( $count + 1 );
5 echo $start + 1;
6 echo ".";
7 echo "</td>\n";
8
9 echo "<td style=\"text-align:left\">";
10 echo "&nbsp;";
11 echo htmlspecialchars( $row[ 'name' ] );
12 echo "</td>\n";

Thanks in advance.

Kind Regards, ZEDD

ZXR
  • 23
  • 1
  • 5
  • 2
    the php tag echo `'"` is redundant, just concatenate it like any normal variable – Kevin Jun 06 '18 at 06:22
  • Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Nigel Ren Jun 06 '18 at 06:38

1 Answers1

1

Don't make it with echo if you already echo it. Just add $row['name'] as a normal variable, try like this:

echo "<tr id='".$row['name'].( ( $start % 2 ) == 0 ? " bgcolor=\"#FFFFFF\"" : " bgcolor=\"#E5E5E5\"" ) .">\n";
tyrlaka
  • 154
  • 1
  • 5
  • 13