0

Update : I found out that the $event_start_date = strtotime($row['event_start_date'])); and $event_end_date = strtotime($row['event_end_date'])); is giving the error.

I'm currently creating an event management website for my assignment. and I get a this localhost is currently unable to handle this request. HTTP ERROR 500 whenever with this piece of code. When I remove it runs perfectly. But strange thing is when i run it in Mozila, it just shows a white blank page, when in chrome it gives me this error. BTW i'm using Uniserver as the localhost.

<?php
        $query = "SELECT * FROM events ;";  

                $db_name = "em";
                $db_host = "127.0.0.1";
                $db_username = "root";
                $db_password = "root";

        if( !($database_connection = mysql_connect($db_host, $db_username, $db_password)))
        {
        die ("Error : Could not connect to database.");
        }


        if( !mysql_select_db($db_name, $database_connection))
        {
        die ("Error : Could not open the database.");
        }


        if ( !($result = mysql_query( $query, $database_connection)) )
        {
            print("Error : Could not execute query.");
            die(mysql_error());
        } else
        {
            $count = mysql_num_rows($result);

            while($row = mysql_fetch_array($result)) {
                $event_id = $row['event_id'];
                $event_name= $row['event_name'];
                $event_description=$row['event_description'];

                $event_venue = $row['event_venue'];
                $event_start_date = strtotime($row['event_start_date']));
                $event_end_date = strtotime($row['event_end_date']));
                //$ticket_type = $row['event_ticket_type'];
                $event_price = $row['event_ticket_price'];
                $event_account = $row['event_account']; 
                $event_image = $row['event_image'];
                $event_bank = $row['event_bank'];



                echo '    <div class="eventbox">
                        <div class="eventimage">
                            <img src="'.$event_image.'" href="" class="eventimagefill">
                        </div>

                        <div class="eventcontent">
                            <h6 style="margin:0px; padding: 0px;color:#303A40;">'.date("F j, Y, g:i A", $event_start_date).'</h6>
                            <h3 style="margin: 0px; padding: 0px; margin-top:5px;color:#303A40;">'.$event_name.'</h3>
                            <h5 style="float:right;margin-top:-25px; margin-right:30px;padding: 0px;color:#fe8c00;font-size:1.2em;">';

                    if($event_price == "0.00")
                    {
                        echo "FREE";
                    } else
                    {
                        echo 'RM '.$event_price;
                    }



                    echo '</h5>

                        </div>

                    </div>';

            }

        }

        mysql_close($database_connection);

    ?>
  • So did you figure it out? – cchoe1 Feb 14 '18 at 06:07
  • 1
    Check your error.log. It will give you more detail information about error. If you are using apache2 as server then you can find it in /var/log/apache2/error.log – Hitesh Shrimali Feb 14 '18 at 07:21
  • 1
    **The `mysql` PHP extension is dead** -- Stop using the [`mysql_*()` PHP functions](http://php.net/manual/en/function.mysql-connect.php). They are old, deprecated since PHP 5.5 and completely removed in PHP 7. Use [`mysqli`](http://php.net/manual/en/book.mysqli.php) or [`PDO_mysql`](http://php.net/manual/en/ref.pdo-mysql.php) instead. Read the answers to [this question](https://stackoverflow.com/q/12859942/4265352) to learn more about why and how. If you are learning PHP from a tutorial then find a better one. One that doesn't teach you to use deprecated MySQL functions and `die()`. – axiac Feb 14 '18 at 13:02

1 Answers1

0
 $event_start_date = strtotime($row['event_start_date']));
 $event_end_date = strtotime($row['event_end_date']));

i think you have give here two brackets

$event_start_date = strtotime($row['event_start_date']);
$event_end_date = strtotime($row['event_end_date']);
Swapnil Kumbhar
  • 440
  • 4
  • 10