0

I am trying to retrive information from the database table but it gives the following error:

Parse error: syntax error, unexpected '$Row' (T_VARIABLE) in

The code is:

require_once('../connect.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT * FROM students_name";            
$result = mysqli_query($dbc, $query);

print ("Student Information Table");
print("<table");
print("<tr>");
print("<td><b>No</b></td>");
print("<td><b>First Name</b></td>");
print("<td><b>Last Name</b></td>");
print("<td><b>Adreess</b></td>");
print("<td><b>Course</b></td>");
print("<td><b>Age</b></td>");
print("</tr>");

//result form the data base
while ($Row = mysqli_fetch_array ($result)){
    print("<tr>");
    print("<td>"$Row[id]"</td>");
    print("<td>"$Row[first_name]"</td>");
    print("<td>"$Row[last_name]"</td>");
    print("<td>"$Row[address]"</td>");
    print("<td>"$Row[course]"</td>");
    print("<td>"$Row[age]"</td>");
    print ("</tr>");
}

mysqli_close ($dbc);
print("</table>");

The error line:

print("<td>"$Row[id]"</td>");

I don't see any syntax error but still doesn't work.

Maihan Nijat
  • 9,054
  • 11
  • 62
  • 110

1 Answers1

2

You don't see a syntax error, but it's there...

print("<td>".$Row['id']."</td>");
print("<td>".$Row['first_name']."</td>");
print("<td>".$Row['last_name']."</td>");
print("<td>".$Row['address']."</td>");
print("<td>".$Row['course']."</td>");
print("<td>".$Row['age']."</td>");

Thanks to @Fred-ii- for pointing this out. You misspelled the table tag:

print("<table>"); // was just "<table"

Even though it doesn't cause the error, it will mess your table up.

Which in HTML source or HTML debugger would throw the following:

Stray start tag "td"

in regards to the missing > for print("<table");

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Kevin Kopf
  • 13,327
  • 14
  • 49
  • 66