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? Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
whelpton Posted February 21, 2009 Author Share Posted February 21, 2009 Awsome, thank you very much. Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.