droidus Posted July 19, 2011 Share Posted July 19, 2011 i am having trouble writing this code: <a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'> i always get confused when it comes to echoing/printing php code. i tried closing with '" . php code...here . "', but it didn't seem to work. the link goes to (when clicked on), ?file=<?php echo [name]?> Quote Link to comment https://forums.phpfreaks.com/topic/242337-printing-php-code/ Share on other sites More sharing options...
premiso Posted July 19, 2011 Share Posted July 19, 2011 If the link is doing that, then it generally means that PHP Is not enabled on the server or you are echoing php code inside of an echo. Show us 5-10 lines around where this code is at so we can get the context better. Quote Link to comment https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244631 Share on other sites More sharing options...
droidus Posted July 19, 2011 Author Share Posted July 19, 2011 print("</td>"); print ("<td align='center'><input name='file[]' type='checkbox' value='$file' /></td>"); print ("<td>" . date ('F d Y H:i:s.', filemtime($file)) . "</td>"); print ("<td><a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>"); } } Quote Link to comment https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244632 Share on other sites More sharing options...
premiso Posted July 19, 2011 Share Posted July 19, 2011 Thanks: print "<td><a href='downloadFile.php?file=". $_FILES['file']['name'] . "'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>"; Is what you should be using. When you are echoing a variable inside of PHP code, you need to concatenate variables onto it (like I just showed you). If you are working out side of PHP, then you would use the echo like you had: ?> <some html here> <td><?php echo $var; ?></td> <?php // more php code ?> Hopefully that makes sense to you. Quote Link to comment https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244633 Share on other sites More sharing options...
droidus Posted July 19, 2011 Author Share Posted July 19, 2011 ok; that works! thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.