Jump to content

elseif parse error :(


DataSpy

Recommended Posts

<?php

if ($order == "etitle") {

    $ordername = English Name;}  <=== line 102

elseif ($order == "type") {

    $ordername = Type;}

else ($order == "entered") {

    $ordername = Date Entered;}

?> 

 

and the error I get is "Parse error: parse error, unexpected T_STRING in C:\Program Files\xampp\htdocs\xampp\www\test\anime2.php on line 102"

 

Thanx in advance any help would be greatly appretiated!

Link to comment
https://forums.phpfreaks.com/topic/37706-elseif-parse-error/
Share on other sites

<?php

if ($order == "etitle") {

    $ordername = 'English Name';}

elseif ($order == "type") {

    $ordername = 'Type';}

else ($order == "entered") {  <=== line 105

    $ordername = 'Date Entered';}

?>

 

Now it says "Parse error: parse error, unexpected '{' in C:\Program Files\xampp\htdocs\xampp\www\test\anime2.php on line 105". 

 

Will the errors ever stop  :'(

Link to comment
https://forums.phpfreaks.com/topic/37706-elseif-parse-error/#findComment-180463
Share on other sites

You can also use a switch statement here:

<?php
switch ($order) {
    case 'etitle':
         $ordername = 'English Title';
         break;
    case 'type':
         $ordername = 'Type';
         break;
    case 'entered':
         $ordername = 'Date Entered';
         break;
    default:
         $ordername = 'Unknown';
}
?>

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/37706-elseif-parse-error/#findComment-180498
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.