-4

Can someone please give me some guidance on how to deal with this error? I'm not a programmer and so have little to no skills / knowledge about this kind of thing. But, I'm keen to learn, and would be really greatful if someone could give me some guidance.

Parse error: syntax error, unexpected 'else' (T_ELSE) on line 10

The code this relates to is below:

<?php 


include 'desciptions.php';
include 'title.php';
$rand=rand(0,67);


else if($rand=='1')
    $desciptions=$d1;
    $title=$m1;

else if($rand=='2')
    $desciptions=$d2;
    $title=$m2;

else if($rand=='0')
    $desciptions=$d0;
        $title=$m0;
?>
Phill Healey
  • 3,084
  • 2
  • 33
  • 67

2 Answers2

0

Change your code to this:

<?php

include 'desciptions.php';
include 'title.php';
$rand = rand(0, 67);


if ($rand == '1') {
    $desciptions = $d1;
    $title = $m1;
} elseif ($rand == '2') {
    $desciptions = $d2;
    $title = $m2;
} elseif ($rand == '0') {
    $desciptions = $d0;
    $title = $m0;
}
?>
Rotimi
  • 4,783
  • 4
  • 18
  • 27
samezedi
  • 621
  • 5
  • 15
0

Remove the first else, add { and } and remove the ticks:

<?php 

include 'desciptions.php';
include 'title.php';
$rand=rand(0,67);

if($rand == 1) {
    $desciptions = $d1;
    $title = $m1;
} else if($rand == 2) {
    $desciptions = $d2;
    $title = $m2;
} else if($rand == 0) {
    $desciptions = $d0;
    $title = $m0;
}
?>

Also maybe fix desciptions to descriptions.

brombeer
  • 8,716
  • 5
  • 21
  • 27