PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
AlbinoJellyfish
Forum Commoner
Posts: 76 Joined: Sun Apr 04, 2004 7:39 pm
Post
by AlbinoJellyfish » Sun Apr 11, 2004 6:47 pm
I want to assign $link to have a string, then a variable. IE
Code: Select all
<?php
$id=$_POST['id'];
$link = "/news/viewnews.php?id="$id;
?>
This doesnt work. It says
Parse error: parse error, unexpected T_VARIABLE in /web/admin/scripts/editnewsp.php on line 10
RFairey
Forum Commoner
Posts: 52 Joined: Fri Jun 06, 2003 5:23 pm
Post
by RFairey » Sun Apr 11, 2004 6:53 pm
You need a period between the first string and the variable. Its the string concatenation operator, and just adds strings together:
Code: Select all
<?php
echo "ab"."cd";
echo "yourlink".$variable;
?>
AlbinoJellyfish
Forum Commoner
Posts: 76 Joined: Sun Apr 04, 2004 7:39 pm
Post
by AlbinoJellyfish » Sun Apr 11, 2004 6:54 pm
ok, thnx. I was thinking a comma, and it also gave me errors. I got it.
nincha
Forum Contributor
Posts: 191 Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA
Post
by nincha » Sun Apr 11, 2004 8:50 pm
can simply do this
Code: Select all
$link = "/news/viewnews.php?id=$id";
*note only for double quotes, not single.