Jump to content

[SOLVED] I cant figure out this echo problem.


whelpton

Recommended Posts

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
Share on other sites

<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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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