this is how is inserted link on line 53.but its giving syntax error.i could not find any mistake as i already put ; at the end of the line but still it is saying missing ; or , please help.

<?php include("../includes/config.php"); ?>
<!DOCTYPE HTML>
<html>
<head>
<title>Admdin Home</title>
<link rel="StyleSheet" href="css/style.css" type="text/css" media="screen">
</head>
<body>
<?php include("includes/header.php"); ?>
<?php include("includes/nav.php"); ?>
<?php include("includes/aside.php"); ?>
<div id="maincontent">

    <div id="breadcrumbs">
        <a href="">Home</a> >
        <a href="">Manage Users</a> >
        List Users
    </div>
    <h2>Teachers List</h2>
</div>
<?php
 if ($_SESSION["isadmin"])
   {

   $con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
    {
   die('Could not connect: ' . mysql_error());

    }



mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM accounts WHERE (type='T')");
echo "<table border='1'>
<tr>
<th>E-mail</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Type</th>
<th>EDIT</th>
<th>DELETE</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
        echo "<td>" . $row['email'] . "</td>";
        echo "<td>" . $row['firstname'] . "</td>";
        echo "<td>" . $row['lastname'] . "</td>";
        echo "<td>" . $row['type'] . "</td>";
        echo "<th><a href="edit-teacher.php">EDIT</a></th> 
        <th><a href="edit-teacher.php">DELETE</a></th>";

  echo "</tr>";
  }
    echo "</table>";

mysql_close($con);
?>

</body>
<?php include("includes/footer.php"); ?>
</html>
<?php
    }
    else
    {
        header("Location: ".$fullpath."login/unauthorized.php");

    }
?>

Dani AI

Generated

The parse error happens because the PHP string that prints your table row was being terminated early by the quotes inside the HTML. When that occurs, the parser reads the next characters as a bare word (T_STRING) and complains about a missing comma or semicolon. Also double-check the line before the one flagged, since a missing ; there often makes the next line look broken. was on the right track; ’s tip about using a syntax-highlighting editor will make these issues obvious.

A few safer patterns that avoid escaping headaches and keep the markup readable. Also consider td for action links as @diafol suggested, since these cells are not headers.

/* 1) Use a single-quoted PHP string with HTML attributes in double quotes */
echo '<td><a href="edit-teacher.php">Edit</a></td>'
   . '<td><a href="edit-teacher.php">Delete</a></td>';
/* 2) Use a heredoc for multi-line readability */
echo <<<HTML
  <td><a href="edit-teacher.php">Edit</a></td>
  <td><a href="edit-teacher.php">Delete</a></td>
HTML;
/* 3) Use printf for clearer intent */
printf('<td><a href="%s">Edit</a></td><td><a href="%s">Delete</a></td>',
       'edit-teacher.php', 'edit-teacher.php');

Two robustness notes you can apply immediately:

  • Escape any data you output into cells: htmlspecialchars($row['email'], ENT_QUOTES, 'UTF-8').
  • If you pass identifiers in the link, build them safely:
$url = 'edit-teacher.php?email=' . rawurlencode($row['email']);
echo '<td><a href="' . $url . '">Edit</a></td>';

Lastly, the mysql_* API you are using has long been deprecated and removed in modern PHP. When you revisit this page, consider migrating to mysqli or PDO with prepared statements to future-proof the code and improve security.

Recommended Answers

All 11 Replies

Line 53 has unescaped double quotes. Use \"

as does line 54
find a code highlighting editor, notepad++ there are dozens, having the colors change as the posted code does on DaniWeb, makes it very easy to find headslap moment errorors

( errorors, headslap moment :) )

echo "<th><a href=edit-teacher.php>EDIT</a></th>
<th><a href=edit-teacher.php>DELETE</a></th>";

use the above code it can work...

just place edit-teacher.php in single quotes rather than placing it in double quotes.. Thats all

Member Avatar for Member #120589

Backslash the double quotes as noted. Are you sure you want that as a <th> instead of a <td>? A th in the left handed columns are common as they may relate to data categories, but I haven't seen them used for this purpose before. Just a question, not a criticism.

i've checked the code by removing double quotes.it was giving the same error and then i put the link in single quotes its still giving the same error...

which quotes should i backslash?? i couldnt get u..im sorry
yup i can use td as well..i think i wanted to use th..td can solve the problem???

this is my code now..please help

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
    echo "<td>" . $row['email'] . "</td>";
    echo "<td>" . $row['firstname'] . "</td>";
    echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['type'] . "</td>";
    echo "<th><a href='edit-teacher.php'>EDIT</a></th> <th><a href='edit-teacher.php'>DELETE</a></th>";
  echo "</tr>";
  }
echo "</table>";

sorry for in convenience..this is what it is saying

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\project\admin\teachers-list.php on line 53

ITS DONE.thankxx Awwl :)

Member Avatar for Member #120589

When you do this?

echo "<th><a href=\"edit-teacher.php\">EDIT</a></th> <th><a href=\"edit-teacher.php\">DELETE</a></th>";

All one one line?

Your original code was ok, you just need "; at the end of line 53

@diafol i didnt put any backslashes just changed double quotes with single ones and the error is vanished.. :) thanx again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.