使用get方法在mysql中使用php变量

in mysql table has 3 column id,name,addr id is auto increment & name and addr has values and I want to get result using get method but it is just showing parse error. . . .

<?php
$id = $_GET['id'];
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    echo 'A valid image file id (numeric) is required to display the image file.';
    exit;
} else {
    $query = mysql_query("SELECT * FROM imgtable where id={$id}");
    while ($res = mysql_fetch_array($query))
    {
?>
<tr><td> <?php echo $res['name']; ?></td><td><img src="<?php echo $res['addr']; ?>" width='200px' height='200px'/></td></tr>
<?php}} ?>

Try out this:

$query = mysqli_query("SELECT * FROM imgtable where id='$id'");

Instead of

$query = mysql_query("SELECT * FROM imgtable where id={$id}");

Obviously, if you switch to mysqli, also use mysqli_fetch_array in the followng.