Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieve data from database

    Hi, I am having a problem with getting the data from my database to appear the way I want it to, it appears just fine in the following form:

    Code:
    echo "
        <p>
        <strong>Name:</strong> $ac_name<br />\n
        <strong>Friend Code:</strong> $friend_code<br />\n
        <strong>Native Fruit:</strong> $native_fruit<br />\n
        <strong>Comments:</strong> $comments
        </p>
    ";
    }
    However, when I put it in this form:

    Code:
    echo "
    <table width="60%"><tr><td width="15">
    AC Name
    </td>
    <td width="15%">
    Friend Code
    </td>
    <td width="15%">
    Native Fruit
    </td>
    <td width="15%">
    Comments
    </td>
    </tr>
    <td width="15%">
    $ac_name
    </td>
    <td width="15%">
    $friend_code
    </td>
    <td width="15%">
    $native_fruit
    </td>
    <td width="15%">
    $comments
    </td>
    </tr>
    </table>
    ";
    }
    I get the error

    Code:
    Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/zeldalin/public_html/form/display_data.php on line 14
    Any suggestions?

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    This is really a php issue, not MySQL.

    I'm not an expert in php, but I'd say the issue is due to your quoting. Try escaping the double quotes within the statement, or use single quotes.

    Code:
    echo "
    <table width='60%'><tr><td width='15'>
    AC Name
    </td>
    <td width='15%'>
    Friend Code
    </td>
    <td width='15%'>
    Native Fruit
    </td>
    <td width='15%'>
    Comments
    </td>
    </tr>
    <td width='15%'>
    $ac_name
    </td>
    <td width='15%'>
    $friend_code
    </td>
    <td width='15%'>
    $native_fruit
    </td>
    <td width='15%'>
    $comments
    </td>
    </tr>
    </table>
    ";
    }

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it's indeed a PHP error, but you best either escape double quotes in a double-quoted string, or use a single-quoted string so that the echoed html is valid. like
    PHP Code:
    echo '
    <table width="60%"><tr><td width="15">
    AC Name
    </td>
    <td width="15%">
    Friend Code
    </td>
    <td width="15%">
    Native Fruit
    </td>
    <td width="15%">
    Comments
    </td>
    </tr>
    <td width="15%">'

    $ac_name ,'
    </td>
    <td width="15%">'
    ,
    $friend_code ,'
    </td>
    <td width="15%">'
    ,
    $native_fruit ,'
    </td>
    <td width="15%">'
    ,
    $comments ,'
    </td>
    </tr>
    </table>
    '
    ;

    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    blah, I knew that >_<

    Thanks!


  •  

    Posting Permissions

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