0

I am developing a search field to retrieve data in the database by filtering by some values from a drop down. I keep getting the following error:

Parse error: syntax error, unexpected '<'

The function I use to retrieve data as follows:

<?php
function show() {
    $connect=mysqli_connect("localhost","root","","tsms");

    $output ='';

    $route = $_POST['from'];

    $query = "SELECT * FROM bus WHERE route='$route'";
    $result = mysqli_query($connect,$query);
    $count = mysqli_num_rows($query);

    for($i=0;$i<$count;$i++) {
        while($row = mysqli_fetch_assoc($result)){
            $imageData = '<img height="80" width="70" src="data:image/jpeg;base64,'.base64_encode( $row['image'] ).'"/>';
            $arrival = $row['arrival_time'];
            $departure = $row['departure_time'];
            $type = $row['bus_type'];
            $class = $row['class'];
            $name = $row['bus_name'];
            $facilities = $row['facilities'];
            $reservation = $row['reservation_fee'];

            $output = '<div style="background-color:lightgrey;width:1300px;border:2px solid blue;padding:5px;margin:5px;height:150px;">'.$imageData.' '.$arrival.' '.$departure.' '.$type.' '.$class.' '.$name.' '.$facilities.' '.$reservation.
            <button class="button">View Seats &raquo;</button>'</div>'; 
        }
        echo $output;
    } 
    mysqli_close($connect);
}
?>
Turnerj
  • 4,258
  • 5
  • 35
  • 52
ragnar1992
  • 23
  • 8
  • Your string literals are wrong and I'm sure the error says on which line it is. Also please always format your code properly, you can see on the preview how it looks and you could see it didn't look proper. Also you're wide open for SQL injection issues, learn how to use parameters. – Sami Kuhmonen Jan 08 '17 at 07:01
  • You have error here – Ahad Jan 08 '17 at 07:04
  • Quote then properly – Ahad Jan 08 '17 at 07:05

1 Answers1

2

You missed the single quotes ' in near <button..........

Change this line

$output = '<div style="background-color:lightgrey;width:1300px;border:2px solid blue;padding:5px;margin:5px;height:150px;">'.$imageData.' '.$arrival.' '.$departure.' '.$type.' '.$class.' '.$name.' '.$facilities.' '.$reservation.
             <button class="button">View Seats &raquo;</button>'</div>'; 

to

$output = '<div style="background-color:lightgrey;width:1300px;border:2px solid blue;padding:5px;margin:5px;height:150px;">'.$imageData.' '.$arrival.' '.$departure.' '.$type.' '.$class.' '.$name.' '.$facilities.' '.$reservation.
             '<button class="button">View Seats &raquo;</button></div>';
Md. Sahadat Hossain
  • 3,210
  • 4
  • 32
  • 55
  • He has obviously messed the single quotes and It's better to explain more what was the OP's issue and what did you do to solve it and not just post an answer. – EhsanT Jan 08 '17 at 07:15