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?

<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>

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.

Archived

This topic is now archived and is closed to further replies.

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