Page 1 of 1

Error when making form

Posted: Wed Jan 18, 2006 12:51 pm
by hobby1
twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I am trying to make a form to go on my website to gather info. But I keep getting this parse error See below for php info and error msg...

Parse error: parse error, unexpected '(' in /home/buyadblo/public_html/display_input.php on line 2

Code: Select all

<?
if (($_POST[func] == "") ($_POST[text1] == "")) 
{    

    header ("Location: generic_form.html" );
    exit;
}
$result = $_POST[func] ($_POST[text1]);
?>
<HTML>
<HEAD>
<TITLE>Generic Input Results</TITLE>
</HEAD>
<BODY>
<? echo "$result"; ?>
<P><a href="generic_form.html">Go Again!</a></p>
</BODY>
</HTML>
twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Re: Error when making form

Posted: Wed Jan 18, 2006 1:04 pm
by neophyte
Welcome to devnetwork. Please use "php" tags when posting code?

I've edited your code and inserted my comments with the code.

Code: Select all

Parse error: parse error, unexpected '(' in /home/buyadblo/public_html/display_input.php on line 2

<?
if ($_POST['func'] == "" && $_POST['text1'] == "") 
{    
  //I"m assuming you wanted both text1 and func to be empty
  //Unless func is defined  use the ' around the array names
    header ("Location: http://somesite/generic_form.html" );
    //I like to use full addresses here.
exit();
//This is good. Some people for get to exit.
}
$result = $_POST['func'] .$_POST['text1'];
// The dot concatenates the variables together
?>
<HTML>
<HEAD>
<TITLE>Generic Input Results</TITLE>
</HEAD>
<BODY>
<? echo "$result"; ?>
<P><a href="generic_form.html">Go Again!</a></p>
</BODY>
</HTML>

Re: Error when making form

Posted: Wed Jan 18, 2006 1:38 pm
by hobby1
Thanks for the help!
neophyte wrote:Welcome to devnetwork. Please use "php" tags when posting code?

I've edited your code and inserted my comments with the code.

Code: Select all

Parse error: parse error, unexpected '(' in /home/buyadblo/public_html/display_input.php on line 2

<?
if ($_POST['func'] == "" && $_POST['text1'] == "") 
{    
  //I"m assuming you wanted both text1 and func to be empty
  //Unless func is defined  use the ' around the array names
    header ("Location: http://somesite/generic_form.html" );
    //I like to use full addresses here.
exit();
//This is good. Some people for get to exit.
}
$result = $_POST['func'] .$_POST['text1'];
// The dot concatenates the variables together
?>
<HTML>
<HEAD>
<TITLE>Generic Input Results</TITLE>
</HEAD>
<BODY>
<? echo "$result"; ?>
<P><a href="generic_form.html">Go Again!</a></p>
</BODY>
</HTML>