Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

If else help

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Ray

VIP Member
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
Close
thanks mate... ill try that... but i need to fiqure out this else command, bcecuase im having the same error on other pages
 
0
Close
Try taking the semi colon off the end of the 'else;' statement.

Lux
 
0
Close
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
Close
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
Close
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
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back