Page 1 of 1
switch
Posted: Tue Nov 11, 2008 4:07 pm
by radium35
what am i doing wrong here? the script echo's all includes at the same time?
$a1=$_POST[first_name];
$a2=$_POST[last_name];
$a3=$_POST[work_phone];
$a4=$_POST[cell_phone];
$a5=$_POST[company];
$a6=$_POST[address];
$a7=$_POST[address_2];
$a8=$_POST[city];
$a9=$_POST[state];
$a10=$_POST[zip];
$a11=$_POST[email];
$a12=$_POST[sem_id];
$a13=$_POST[sem_title];
$a14=$_POST[sem_month];
$a15=$_POST[sem_day];
$a16=$_POST[sem_year];
$a17=$_POST[sem_time_hr];
$a18=$_POST[sem_time_min];
$a19=$_POST[sem_time_day];
$a20=$_POST[payment_type];
$paypalbutton = (include 'sem_paypalbutton.php');
$ccpayment = (include 'sem_ccpayment.php');
$checkpayment = (include 'sem_checkpayment.php');
switch ($a20) {
case "Pay Pal":
echo "$paypalbutton";
break;
case "Credit Card":
echo "$ccpayment";
break;
case "Check":
echo "$checkpayment";
break;
}
Re: switch
Posted: Tue Nov 11, 2008 4:28 pm
by requinix
Don't do the include until you need it.
Code: Select all
switch ($a20) {
case "Pay Pal":
include 'sem_paypalbutton.php'
break;
case "Credit Card":
include 'sem_ccpayment.php'
break;
case "Check":
include 'sem_checkpayment.php'
break;
}
Re: switch
Posted: Tue Nov 11, 2008 4:32 pm
by Mark Baker
Are there any echo or print statements inside your included files?
I'm assuming that it does have a return
Re: switch
Posted: Tue Nov 11, 2008 4:39 pm
by radium35
tasairis wrote:Don't do the include until you need it.
Code: Select all
switch ($a20) {
case "Pay Pal":
include 'sem_paypalbutton.php'
break;
case "Credit Card":
include 'sem_ccpayment.php'
break;
case "Check":
include 'sem_checkpayment.php'
break;
}
This worked perfect

thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
Re: switch
Posted: Tue Nov 11, 2008 4:40 pm
by radium35
Mark Baker wrote:Are there any echo or print statements inside your included files?
I'm assuming that it does have a return
ne, the include file has the payment information
Re: switch
Posted: Tue Nov 11, 2008 4:45 pm
by requinix
radium35 wrote:This worked perfect

thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
Re: switch
Posted: Tue Nov 11, 2008 4:46 pm
by radium35
tasairis wrote:radium35 wrote:This worked perfect

thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
umm... ok

Re: switch
Posted: Tue Nov 11, 2008 5:01 pm
by requinix
radium35 wrote:tasairis wrote:radium35 wrote:This worked perfect

thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
umm... ok

Ever tried to do this?
Code: Select all
function test() {
echo "three";
}
$three = test();
echo "one plus two is " . $three;
It doesn't work the way you want for the exact same reason.
Re: switch
Posted: Tue Nov 11, 2008 5:10 pm
by radium35
ok, i get it. That makes sense now.
