I wrote this code and when I run the page I get the parse error :-

Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\view.php on line 30

my code is :-

i checked my whole code, i was unable to find the error

<?php
$page_title="View Users";
include("header.html");
include("nav.html");
?>
<div id="content">
<?php
$num=
require_once("connect.php");
$q="SELECT first_name, last_name, user_id FROM users";
$r=mysql_query($q,$dbc);
$num=mysql_num_rows($r);
echo "<center>Total no. of users registered : ".$num."<br /><br /></center>";
if($r)
{
	echo '<table align="center" border="2" cellspacing="3" cellpadding="3" width="100%">
	     <tr><td align="left"><b>Edit</b></td>
		 <td align="left"><b>Delete</b></td>
		 <td align="left"><b>ID</b></td>
		 <td align="left"><b>First Name</b></td>
		 <td align="Left"><b>Last Name</b></td>
		 </tr>';
		 while($row=mysql_fetch_array($r,MYSQL_ASSOC))
		 {
			 echo '<tr> 
			 <td align="center"><a href="edit.php?id="'.$row['user_id'].'>Edit</a></td>'.
			 '<td align="center"><a href="delete.php?id="'.$row['user_id'].'Delete</a></td>'.
			 '<td align="center">'.$row['user_id'].'</td>'.
			 '<td align="left">'.$row['first_name'].'</td>'.
			 '<td align="center">'.$row.['last_name'].'</td>'.
			 '</tr>';
		 }
	echo '</table>';
}
mysql_free_result($r);			 
?>
</div>
<?php
include("footer.html");
?>

I fixed the error, but now I am having a different problem now. When I go on the generated page's edit and delete link, i get a link but i should display the link like edit.php?id=$id and delete.php?id=$id but instead it's displaying like edit.php?id= and delete.php$id= and not displaying the generated id in the URL. I have also attached a screen shot.

You have missed the close '>' of <a> tag in line 27

'<td align="center"><a href="delete.php?id="'.$row['user_id'].' > Delete</a></td>'.

mark this thread as unsolved or start a new thread. Then only it visible to lot of users.

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.