Page 1 of 1

PHP variable content disappears from one line to next

Posted: Fri 13. Jan 2006, 01:39
by Microbe
I have the following code in a contact form I am building (the phpwcms built in contact form breaks the application)

Code: Select all

[PHP]
if($_GET["to"]> ""){
	switch ($_GET["to"]) {
	    case "president":
		$email="email@domain";
		$recipient = "The president";
		break;
--SNIP--
	}

echo(" sw1 = " . $recipient);

}
[/PHP]

[PHP]
    echo(" sw2 = " . $recipient);
[/PHP]
can anyone explain why the output is

Code: Select all

val 1 = The president val 2 =
The variable content has been lost from one line to the next

Posted: Fri 13. Jan 2006, 02:34
by DeXXus
SUBSTITUTE:

Code: Select all

<?php
FOR:

Code: Select all

[PHP]
and SUBSTITUTE:

Code: Select all

?>
FOR:

Code: Select all

[/PHP]
and think about it :wink:

Posted: Fri 13. Jan 2006, 02:49
by Microbe
DeXXus wrote:SUBSTITUTE:

Code: Select all

<?php
FOR:

Code: Select all

[PHP]
and SUBSTITUTE:

Code: Select all

?>
FOR:

Code: Select all

[/PHP]
and think about it :wink:
I am working around it now.

But I can only assume that the variables end up local within functions. Am I close? :?:

Posted: Fri 13. Jan 2006, 04:37
by DeXXus
Microbe wrote: But I can only assume that the variables end up local within functions. Am I close? :?:
:wink: http://www.phpwcms.de/forum/viewtopic.php?p=53632#53632

Posted: Fri 13. Jan 2006, 04:45
by Microbe
DeXXus wrote:
Microbe wrote: But I can only assume that the variables end up local within functions. Am I close? :?:
:wink: http://www.phpwcms.de/forum/viewtopic.php?p=53632#53632
heh! Thanks so much for that.

I had just seen that article a short while ago while trying to figure out how to make the contact form produce

Code: Select all

    <option value="1">Option one</option>
    <option value="2">Option two</option>
    <option value="3">Option three</option> 
Still havn't done it.

I know the documentation is a work in progress, but it really needs some examples.