can someone fix this parse error?

Discussion in 'PHP' started by promotingspace.net, Jul 16, 2007.

  1. #1
    Hi
    Can someone fix this code:
      echo "<a href=\"readarticle.php?id=$id\">{$row['title']}</a>" .'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. 'by'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. {$row['name']}. "<br />";
    PHP:
    It is in the code below
    <?php
    include'global.php';
    $result=mysql_query("SELECT * FROM articles ORDER BY id DESC LIMIT 20");
    ?>
    <html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
    <p align=right>
    <?
    while( $row=mysql_fetch_array($result))  {
      $id=$row['id']; 
      echo "<a href=\"readarticle.php?id=$id\">{$row['title']}</a>" .'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. 'by'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. {$row['name']}. "<br />";
    }
    ?>
    PHP:
    and sending:
    Parse error: parse error in g:\programs\easyphp1-8\www\takfekr\htdocs\home.php on line 13
     
    promotingspace.net, Jul 16, 2007 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Right at the end of that line you have {$row['name']} as a straight variable (not inside a double quoted string). The curly brackets are only used when embedded in a double quoted string. Try just $row['name'] instead.
     
    TwistMyArm, Jul 16, 2007 IP
  3. Weizheng

    Weizheng Peon

    Messages:
    93
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Very sharp eyes you have.
     
    Weizheng, Jul 16, 2007 IP