Jump to content

Tables and Creating links Within a PhP ECHO


Ziph

Recommended Posts

Dear phpFreaks,

I am trying to echo something from my database into a table now when i try this i get this error.

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/gosu/public_html/hahaha/lollolo.php on line 63

 

<?php

echo "<table>

 

<tr height='100px'></tr>

<tr><td><img src='documents.jpg' /></td></tr>

<tr height='20px'></tr>";

  $checkdocuments = mysql_query("SELECT * FROM uploads WHERE username='$username' AND sortlist='Documents' ");

while($row1 = mysql_fetch_array($checkdocuments))

{

echo "<tr><td>$row1['username']</td></tr>"; // LINE 63

}

 

echo "</table>";

?>

 

 

Link to comment
Share on other sites

" " allows you to put in $variables and will see them fine.  If you use ' ' you will have to concatenate your variables and array values using (.).  However when you use " " it will not see your array key as it will treat ' ' as normal characters.  But I think I've just learnt from kenrbnsn that you can use { } to make php see the $array['key'].

Link to comment
Share on other sites

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/gosuh0/public_html/upload/uploadform.php on line 63

keep getting this error.

 

 

echo "<tr><td>" . $row1['name'] . "</td><td>" . $row1['lastname'] . "</td><td>" '<a href="' . $row1['link'] . '">Click Here</a>' "</td><td>" . $row1['poll'] . "</td></tr>";

 

 

Link to comment
Share on other sites

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/gosuh0/public_html/upload/uploadform.php on line 63

keep getting this error.

 

 

echo "<tr><td>" . $row1['name'] . "</td><td>" . $row1['lastname'] . "</td><td>" '<a href="' . $row1['link'] . '">Click Here</a>' "</td><td>" . $row1['poll'] . "</td></tr>";

 

 

 

Your Code:
echo "<tr><td>" . $row1['name'] . "</td><td>" . $row1['lastname'] . "</td><td>" '<a href="' . $row1['link'] . '">Click Here</a>' "</td><td>" . $row1['poll'] . "</td></tr>";

Proper Code:
echo '<tr><td>' . $row1['name'] . '</td><td>' . $row1['lastname'] . '</td><td><a href="' . $row1['link'] . '">Click Here</a></td><td>' . $row1['poll'] . '</td></tr>';

 

As a tip...try to get used to using single quotes for strings unless a variable is enclosed in the quotes. It processes the echo faster than doing everything in double quotes. If double quotes are used, PHP has to spend overhead searching for a variable to expand in there before it can process out the echo value. Realistically you may not even have to use the double quotes I put in the Proper Code to work, but you do to meet W3C DOM requiresments for tag attributes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.