Forum Moderators: coopster

Message Too Old, No Replies

Simple PHP Link Thing? problem!

         

Spiceydog

9:14 pm on May 13, 2008 (gmt 0)

10+ Year Member



So what I have is a variable... that I want to be a link when I echo it in other places on the page. Normally a link would be easy but in this case I also need an onClick that posts data. Not quite sure if this is how I would do it but here is what I have so far. When I use this I get an error reading: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/pv3/public_html/school/input2.php on line 113

Here is what I have so far:

$name = "<a href='http://www.example.com/school/output.php' onclick='post.searchname.value=$data['name']'>$data['name']</a>";

[edited by: eelixduppy at 10:32 pm (utc) on May 13, 2008]
[edit reason] example.com [/edit]

Wolf_man

9:59 pm on May 13, 2008 (gmt 0)

10+ Year Member



why not seperate the variables from the plain text, its a better way to do it, and also use single quotes instead of double.

$name = '<a href=\'http://www.example.com/school/output.php\' onclick=\'post.searchname.value='.$data['name'].'\'>'.$data['name'].'</a>';

[edited by: Wolf_man at 10:01 pm (utc) on May 13, 2008]

[edited by: eelixduppy at 10:33 pm (utc) on May 13, 2008]
[edit reason] example.com [/edit]

Spiceydog

10:31 pm on May 13, 2008 (gmt 0)

10+ Year Member



That works almost perfectly.. but for some reason it isn't posting the data. That makes me think that post.searchname.value is what is wrong... hmm... anyone know?