This question already has an answer here:
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;
?>
</div>
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
.
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;
}
?>