Welcome to WebmasterWorld Guest from 3.227.2.109

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Simple PHP Link Thing? problem!

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

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


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]

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

New User

10+ Year Member

joined:Aug 18, 2004
posts:15
votes: 0


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]

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

Junior Member

10+ Year Member

joined:May 7, 2008
posts:45
votes: 0


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?