SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: href error

  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    href error

    I am having a syntax error(bolded) with this line of code. Help needed!!!! I am new to php!

    By the way, this line of code is in a while loop.

    Code:
    while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
    echo "<tr><td>" . $row['id'] . "</td><td>" . $row['date'] . "</td><td>" . $row['type'] . "</td><td>" . $row['size'] ."</td><td>" . $row['currency_pair'] ."</td><td>" . $row['entry'] ."</td><td>" . $row['stoploss'] ."</td><td>" . $row['takeprofit'] ."</td><td>" . $row['dateclose'] ."</td><td>" . $row['close'] ."</td><td>" . $row['profitloss'] . "</td><td>"<a href= 'copytrade.php?id= .$row['id'].'">copy</a></td></tr>";
    }

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,212
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    You've got the " in the wrong place in that bold section. Try this:

    Code:
    <td><a href='copytrade.php?id=" . $row['id'] . "'>copy</a></td>
    (I may not have that quite right, but it's closer. )

  3. #3
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I know Ralph has already answered your question but I can't bare to see an echo statement mangled together as it makes finding errors harder and quite annoying to update, to counter this (and I know others have their view) but I always recommend you concatenate your echo statement as a string but so each specific TD in your case is on its own line so its clear as to what goes where. Also you shouldn't put comments after brackets as you will find in the future that it makes your lines very long where as putting them on the line before makes it clear and concise as to what it is your doing.

    PHP Code:
    // Creates a loop to loop through results
    while ($row mysql_fetch_array($result)) {
        echo 
    "<tr>" +
            
    "    <td>" $row['id'] . "</td>" +
            
    "    <td>" $row['date'] . "</td>" +
            
    "    <td>" $row['type'] . "</td>" +
            
    "    <td>" $row['size'] ."</td>" +
            
    "    <td>" $row['currency_pair'] ."</td>" +
            
    "    <td>" $row['entry'] ."</td><" +
            
    "    <td>" $row['stoploss'] ."</td>" +
            
    "    <td>" $row['takeprofit'] ."</td>" +
            
    "    <td>" $row['dateclose'] ."</td>" +
            
    "    <td>" $row['close'] ."</td>" +
            
    "    <td>" $row['profitloss'] . "</td>" +
            
    "    <td><a href= 'copytrade.php?id=" $row['id'] . "'>copy</a></td>" +
            
    "</tr>";

    Please don't take this as me criticising you, its simply some constructive criticism to help you in the future.

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I don't think you want + there. A . OR , would work.
    - Robert


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •