Dynadot โ€” .com Registration $8.99

If else help

Spaceship Spaceship
Watch
Impact
167
ok.. here is my problem I get the following error from the code. I cant fiqure out what is wrong with my code.


Parse error: parse error, unexpected T_ELSE in /home/hughraho/public_html/inc/order/1.php on line 37


PHP:
if ($plan=="");
{
$plan = $_POST['plan'];
}
if ($plan=="1");
{
$acctplan = "hughraho_starter";
$vplan = "Starter";
}
if ($plan=="2");
{
$acctplan = "hughraho_advanced";
$vplan = "Advanced";
}

if ($plan=="3");
{
$acctplan = "hughraho_professional";
$vplan = "Professional";
}else;{
$acctplan = "hughraho_error";
$vplan = "Error";
	}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
0
•••
thanks mate... ill try that... but i need to fiqure out this else command, bcecuase im having the same error on other pages
 
0
•••
Try taking the semi colon off the end of the 'else;' statement.

Lux
 
0
•••
I know for a fact it doesnt matter if thats there.

For my problem... I found that there was a ; next to all the if statements.. I have no clue why i pud them there while i new they didnt belong there
 
0
•••
after all the if lines you have a ; which should not be there (should only be after each line within the statment)

the same goes for the else line as luxinterior stated.

Having these there you are confusing the php parser as it thinks it has reached the end of a line of code when it has not.

Regarding php errors sometimes being a red herring. The errors are ussually quite accurate sometimes the line number is wrong, if it is it's ussually the line before the error is on.
 
0
•••
Try...

PHP:
if (!isset($_POST['plan']))
{
$plan = $_POST['plan'];
}
elseif ($plan=="1")
{
$acctplan = "hughraho_starter";
$vplan = "Starter";
}
elseif ($plan=="2")
{
$acctplan = "hughraho_advanced";
$vplan = "Advanced";
}

elseif ($plan=="3")
{
$acctplan = "hughraho_professional";
$vplan = "Professional";
}
else
{
$acctplan = "hughraho_error";
$vplan = "Error";
}
 
Last edited:
0
•••
that code is still wrong miseria

anyway why not just do the following :-

PHP:
switch ($plan) {
case 1:
   $acctplan = "hughraho_starter";
   $vplan = "Starter"; 
   break;
case 2:
   $acctplan = "hughraho_advanced";
   $vplan = "Advanced"; 
   break;
case 3:
   $acctplan = "hughraho_professional";
   $vplan = "Professional"; 
   break;
default:
   $acctplan = "hughraho_error";
   $vplan = "Error";
}
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back