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>";

?>

 

 

" " 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'].

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>";

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.