colossus
08-11-2004, 12:00 AM
I am making a script that takes the options selected by a person and then submits them to paypal to the order form. The problem is, I have multiple switch statements which define variables, do some math, and then echo a bunch of info with those variables. Problem is, some of my variables weren't reporting. I turned on error reporting all the way and it said that a series of my variables (all of which weren't returning) were undefined!. Here is a snippet of the code.
<?php
$beginnerbutton = "
<center>You have selected the Beginner Hosting Plan and " . $l . " for your payment length. <a href='hosting.html'>Change?</a><br /><br /></center><center><form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
//OMITTED
<input type='hidden' name='a3' value='" . $amount . "'>
<input type='hidden' name='p3' value='" . $p3 . "'>
<input type='hidden' name='t3' value='" . $t3 . "'>
//OMITTED
";
//other variables like $beginnerbutton omitted
$l = $_GET['l'];
$q = $_GET['q'];
switch ($q){
case "beginner":
$plancost = 1.00;
sl();
echo $beginnerbutton;
break;
//other cases like beginner omitted
};
function sl(){
switch ($l){
case "Monthly":
$amount = $plancost * 1;
$p3 = 1;
$t3 = "M";
break;
//other cases like Monthly omitted
};
};
?>
Here are the errors I'm getting:
Notice: Undefined variable: amount in /home/percept/public_html/signuptest.php on line 95
Notice: Undefined variable: p3 in /home/percept/public_html/signuptest.php on line 96
Notice: Undefined variable: t3 in /home/percept/public_html/signuptest.php on line 97
Notice: Undefined variable: l in /home/percept/public_html/signuptest.php on line 167
And all of them are returned three times. The line numbers don't matter.
<?php
$beginnerbutton = "
<center>You have selected the Beginner Hosting Plan and " . $l . " for your payment length. <a href='hosting.html'>Change?</a><br /><br /></center><center><form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
//OMITTED
<input type='hidden' name='a3' value='" . $amount . "'>
<input type='hidden' name='p3' value='" . $p3 . "'>
<input type='hidden' name='t3' value='" . $t3 . "'>
//OMITTED
";
//other variables like $beginnerbutton omitted
$l = $_GET['l'];
$q = $_GET['q'];
switch ($q){
case "beginner":
$plancost = 1.00;
sl();
echo $beginnerbutton;
break;
//other cases like beginner omitted
};
function sl(){
switch ($l){
case "Monthly":
$amount = $plancost * 1;
$p3 = 1;
$t3 = "M";
break;
//other cases like Monthly omitted
};
};
?>
Here are the errors I'm getting:
Notice: Undefined variable: amount in /home/percept/public_html/signuptest.php on line 95
Notice: Undefined variable: p3 in /home/percept/public_html/signuptest.php on line 96
Notice: Undefined variable: t3 in /home/percept/public_html/signuptest.php on line 97
Notice: Undefined variable: l in /home/percept/public_html/signuptest.php on line 167
And all of them are returned three times. The line numbers don't matter.
