Forum Moderators: coopster

Message Too Old, No Replies

Textareas and Variable

         

quozt

7:27 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



<p>Desc:<br /> <textarea name="content" cols="100" rows="20"><?echo $textarea;?></textarea></p>

is what i have but all it displays is <?echo $textarea;?> ive tryed $textarea and other code... any ideas what i can use

coopster

7:58 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It seems as though the file is not parsing the PHP. Try renaming the file with a .php extension first to see if your PHP parser is working.

quozt

8:34 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



the file is named as php

Timotheos

8:47 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm it works for me.

<? $textarea = "test";?>
<p>Desc:<br /> <textarea cols="100" rows="20" name="content"><?echo $textarea;?></textarea></p>

Does your php set up allow for the short tag (<? vs <?php)?
Is there anything else before this that is not closed properly? Look at the source. Maybe check it in an html validator?

quozt

9:13 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



no

print '<form action="teachers.php" method="post">
<p>Directory: <input type="text" name="link" size="40" maxsize="100" value="' . $row['link'] . '"/></p>
<? $textarea = "test";?>
<p>Desc:<br /> <textarea cols="100" rows="20" name="content"><?echo $textarea;?></textarea></p>
<input type="hidden" name="id" value="' . $_GET['id'] . '" />
<input type="submit" name="submit" value="Update this Entry!" />
</form>';

jatar_k

9:17 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you seem to have

<? $textarea = "test";?> and <?echo $textarea;?>

inside your actual print statement

try this chunk, I removed the print statement all together

<form action="teachers.php" method="post">
<p>Directory: <input type="text" name="link" size="40" maxsize="100" value="<?php echo $row['link'];?>"/></p>
<p>Desc:<br /> <textarea cols="100" rows="20" name="content"><?php echo $textarea;?></textarea></p>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>" />
<input type="submit" name="submit" value="Update this Entry!" />
</form>

you may have to drop out of php parsing to make this work.

precede it with a?> if so

quozt

9:23 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



thanks that worked :) this forum is a real help to me you should all be proud of ur self

quozt

9:39 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



ok 1 more question

$dir = $row['link'];
$textarea = file_get_contents("../../subjects/$dir/$filename.htm");

any idea why this doesnt get the directory from my database

Timotheos

9:45 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah ha the bigger picture reveals the problem. When you use single quotes around the string to print (or echo) then it is not parsed for variables. If you used double quotes then it would have worked but you would then have to escape any double quotes in the html tags. Best to do it jatar_k's way... as usual ;-)

jatar_k

9:47 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would need to know where $row['link'] and $filename came from

have you tried testing the values to see what actually ends up in the vars?

$dir = $row['link'];
$mypath = "../../subjects/" . $dir . "/" . $filename . ".htm";
echo $mypath;
$textarea = file_get_contents($mypath);

I did that the concat way for mo reason in particular. Is that path correct?

You are looking for a file 2 dirs above the one you are in, then into the subjects dir and then into a dir to be determined and then there's the file?

That path won't port to other dirs at all, it will break or will need to be hard coded.

quozt

9:49 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



$dir = $row['link'];
$textarea = file_get_contents("../../subjects/".$dir."/".$filename.".htm");

ive changed it to that..shouldnt that work

jatar_k

9:56 pm on Apr 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that's not what i posted though

try echo'ing the contents of the variables to see if they have the proper values stored in them.

quozt

9:58 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



k i figured it out i had $row = mysql_fetch_array ($r); in the wrong placve