Ziph Posted September 16, 2008 Share Posted September 16, 2008 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 https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/ Share on other sites More sharing options...
envexlabs Posted September 16, 2008 Share Posted September 16, 2008 echo "<tr><td>$row1[username]</td></tr>"; try removing the ' from the variable name. Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642930 Share on other sites More sharing options...
Ziph Posted September 16, 2008 Author Share Posted September 16, 2008 echo "<tr><td>$row1[username]</td></tr>"; try removing the ' from the variable name. great! Atleast im not getting the error anymore tho it still doesnt show up will take a look at that myself =)) tnx allot again. Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642933 Share on other sites More sharing options...
kenrbnsn Posted September 16, 2008 Share Posted September 16, 2008 That line should be written as <?php echo "<tr><td>{$row1['username']}</td></tr>"; ?> or <?php echo '<tr><td>' . $row1['username'] . "</td></tr>"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642934 Share on other sites More sharing options...
Ziph Posted September 16, 2008 Author Share Posted September 16, 2008 K tnx allot btw i also found why it didnt print anyhing =) also can i ask what is the reason between '<tr><td>' and "</td></tr>" and not both ' ' or " " Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642936 Share on other sites More sharing options...
scottybwoy Posted September 16, 2008 Share Posted September 16, 2008 " " 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 https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642960 Share on other sites More sharing options...
Ziph Posted September 16, 2008 Author Share Posted September 16, 2008 echo '<tr><td>' . $row1['link'] . "</td></tr>"; output = "http://www.google.nl" now I want the output to be this "Click Here" $row1[<a href='filelink'>Click Here </a>] didnt really work out =p any hints ? Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642975 Share on other sites More sharing options...
agod Posted September 16, 2008 Share Posted September 16, 2008 echo "<tr><td><a href=" . $row1[link] . ">click here< / a ></td></tr>"; does that work? Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642985 Share on other sites More sharing options...
kodosai Posted September 16, 2008 Share Posted September 16, 2008 now I want the output to be this "Click Here" $row1[<a href='filelink'>Click Here </a>] didnt really work out =p any hints ? echo '<a href="' . $row1['filelink'] . '">Click Here</a>'; Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642986 Share on other sites More sharing options...
Ziph Posted September 16, 2008 Author Share Posted September 16, 2008 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 https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-642995 Share on other sites More sharing options...
Ziph Posted September 16, 2008 Author Share Posted September 16, 2008 oh sorry error should be Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/gosuh0/public_html/upload/uploadform.php on line 63 so i guess that means something is still wrogn with the ' or " Link to comment https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-643014 Share on other sites More sharing options...
kodosai Posted September 16, 2008 Share Posted September 16, 2008 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 https://forums.phpfreaks.com/topic/124501-tables-and-creating-links-within-a-php-echo/#findComment-643058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.