n00b question

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

Post Reply
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

n00b question

Post 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
RFairey
Forum Commoner
Posts: 52
Joined: Fri Jun 06, 2003 5:23 pm

Post 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;

?>
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

Post by AlbinoJellyfish »

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 »

can simply do this

Code: Select all

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