I'm currently developing a PHP project in PhpStorm using WAMP.
When I run my project I am getting '500 internal server error'. This error shows when I make code changes to a certain php file within my project. For example, I added a name attribute to a html input tag, and this resulted in '500 internal server error'.
Can somebody please advice on this error.
<?php
require_once 'databaseLoginCredentials.php';
$connection = new mysqli($db_hostname, $db_username, $db_password, $db_name);
if ($connection->connect_error)
{
die("Connection failed " . $connection->connect_error);
}
$sql = ("SELECT * FROM tbl_patientdetails pd INNER JOIN tbl_doctors dr ON pd.pd_registerDoctorId = dr.dr_Id");
$result = $connection->query($sql);
if ($result->num_rows > 0 ) {
while ($row = $result->fetch_object())
{
echo '<tr>';
echo '<td><button name="btn-edit" id="btn-edit" value="Edit" onclick="populatePatientDetailsForm()">' . 'Edit' .'</button></td>';
echo '<td><button name="btn-delete" id="btn-delete" value="Delete" onclick="">' . 'Delete' .'</button></td>';
echo '<td>' . $row->pd_id . '</td>';
echo '<td>' . $row->pd_forename . '</td>';
echo '<td>' . $row->pd_lastname . '</td>';
echo '<td>' . $row->pd_dateOfBirth . '</td>';
echo '<td>' . $row->pd_gender . '</td>';
echo '<td>' . $row->dr_id . '</td>';
echo '<td>' . $row->pd_address . ' </td>';
echo '<td>' . $row->pd_postcode . '</td>';
echo '<td>' . $row->pd_phoneNumber .'</td>';
echo '<td>' . $row->pd_email .'</td>';
echo '</tr>';
}
} else
{
echo "0 Patients Returned";
}
$connection->close();
?> <!--END OF PHP-->
require_once 'databaseLoginCredentials.php';
if ($_POST['btn-submit']) {
$id = $_POST['txt-patientId'];
$forename = $_POST['txt-forename'];
$surname = $_POST['txt-surname'];
$dateOfBirth = $_POST['txt-dateOfBirth'];
$gender = $_POST['ddl-gender'];
$doctorId = $_POST['ddl-doctor'];
$address = $_POST['txt-address'];
$postcode = $_POST['txt-postcode'];
$phoneNumeber = $_POST['txt-phoneNumber'];
$email = $_POST['txt-email'];
$conn = new mysqli($db_hostname, $db_username, $db_password, $db_name);
if ($conn->connect_error) {
die("Connection failed: (" . $conn->connect_error);
}
$sql = ("Update tbl_patientdetails
SET pd_forename = '$forename',
pd_lastname = '$surname',
pd_dateOfBirth = '$dateOfBirth',
pd_gender = '$gender',
pd_registerDoctorId = '$doctorId',
pd_address = '$address',
pd_postcode = '$postcode',
pd_phoneNumber = '$phoneNumeber',
pd_email = '$email',
WHERE pd_id = '$id'");
if ($conn->query($sql) === TRUE) {
echo "Success: ' .$id' ',' ' .$forename' Please redirect me Joe";
} else {
echo " error Joe: " . $conn->error;
//Return to patiend Details page
}
$conn->close();
}