Welcome to WebmasterWorld Guest from 54.145.166.96

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php problem.

a newby question.

   
6:22 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



hello, i'm new with php.
i'm having trouble and hope you guys can help me.

The line:
echo "<title>"$sub;".bestevanhetnet.nl</title>";

the error:
Parse error: parse error, expecting `','' or `';'' in /usr/local/slash/apache/vhosts/bestevanhetnet.nl/httpdocs/test/test-header.php on line 8

what am i dooing wrong? shou;d i use the 'subpage' variable instead? or is it a obvous problem?

i don't want to programm a lot php, i just need this line.

6:28 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



ikbenhet1,

It is probably the semicolon (;) behind $sub. Just remove it. You should also change add . to the second and third ":

echo "<title>".$sub.".yourserver.nl</title>";

NN

[edited by: NameNick at 6:31 pm (utc) on Oct. 29, 2002]

6:30 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



I'm not quite clear what you are trying to echo, but the syntax looks incorrect! How about:

echo "<title>" . $sub . ".bestevanhetnet.nl</title>";

If not, give me an example of what you require to be output!

6:30 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



echo "<title>"$sub;".title</title>";

I- echo "<title>".$sub."title</title>";
II- echo "<title>$sub title</title>";

When you use quotes to echo a string, you have to concatenate (?) the next quotes or variables with a period, like in example I.
Another way is putting the variable inside the quotes, like in example II. Although sometimes, you can't or shouldn't put a variable inside quotes.

6:30 pm on Oct 29, 2002 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



just slap another dot in there

echo "<title>".$sub.".bestevanhetnet.nl</title>";

7:10 pm on Oct 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo "<title>", $sub, ".bestevanhetnet.nl</title>";

might be more efficient.

Andreas

11:47 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



<html>
<head>
<title><? echo $sub ?>.bestevanhetnet.nl</title>
</head>

Yet another way of doing it. :o

4:32 pm on Nov 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo "<title>", $sub, ".bestevanhetnet.nl</title>";

might be more efficient.

Why commas instead of a period? Not sure I understand that.

I can see:

echo "<title>" . $sub . ".bestevanhetnet.nl</title>";

6:13 pm on Nov 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why commas instead of a period? Not sure I understand that.

With commas, it's a list of arguments to 'echo'. With periods, the argument to 'echo' is a single string, which is the result of multiple string concatenations. The end result is the same, but the list of arguments is processed more efficiently.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month