Page 1 of 1

n00b question

Posted: Sun Apr 11, 2004 6:47 pm
by AlbinoJellyfish
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

Posted: Sun Apr 11, 2004 6:53 pm
by RFairey
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;

?>

Posted: Sun Apr 11, 2004 6:54 pm
by AlbinoJellyfish
ok, thnx. I was thinking a comma, and it also gave me errors. I got it.

Posted: Sun Apr 11, 2004 8:50 pm
by nincha
can simply do this

Code: Select all

$link = "/news/viewnews.php?id=$id";
*note only for double quotes, not single.