whelpton Posted February 21, 2009 Share Posted February 21, 2009 Im trying to echo a text file in my form using the following code: <label>Band Name <input name="save" type="text" id="save" value="<?php echo'/home/alport/public_html/".$_SESSION['s_username']."/text/name.txt'); ?>" /> </label> Ive used something similar before with sucess, but this time it gives me the following error: Parse error: syntax error, unexpected T_STRING in /home/alport/public_html/shared/bandedit/functions/bandname.php on line 5 Can anyone help me out please? Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/ Share on other sites More sharing options...
Cal Posted February 21, 2009 Share Posted February 21, 2009 <label>Band Name <input name="save" type="text" id="save" value="<?php echo'/home/alport/public_html/".$_SESSION['s_username']."/text/name.txt'); ?>" /> </label> You started with single quotes then used double, use the same type: <label>Band Name <input name="save" type="text" id="save" value="<?php echo"/home/alport/public_html/".$_SESSION['s_username']."/text/name.txt"; ?>" /> </label> Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/#findComment-767855 Share on other sites More sharing options...
whelpton Posted February 21, 2009 Author Share Posted February 21, 2009 Awsome, thank you very much. Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/#findComment-767860 Share on other sites More sharing options...
Cal Posted February 21, 2009 Share Posted February 21, 2009 if you wanted to actualy get the contents of the file use: <label>Band Name <input name="save" type="text" id="save" value="<?php echo file_get_contents("/home/alport/public_html/".$_SESSION['s_username']."/text/name.txt"); ?>" /> </label> Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/#findComment-767863 Share on other sites More sharing options...
whelpton Posted February 21, 2009 Author Share Posted February 21, 2009 Thanks for the secondary info, Ive just figured that out myself, just wondering... is there any difference between using get_file_contents and include? using include seems to be working fine. Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/#findComment-767865 Share on other sites More sharing options...
GingerRobot Posted February 21, 2009 Share Posted February 21, 2009 There is a difference, though in this case either works. Including a file is (almost) identical to having the contents of that file in the one that did the including. Using file_get_contents returns a string with the file contents in it. So, if you wanted to run some code in another php file, you'd want to include it. If you wanted to look through the code and find out if a variable was in it, for example, you'd need to use file_get_contents. Link to comment https://forums.phpfreaks.com/topic/146262-solved-i-cant-figure-out-this-echo-problem/#findComment-767867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.