I am working on posting a CRUD Application to where the user logs in first. The application is made with 2 MySQL tables; one for logging in and the other for the CRUD values. This example hasn’t worked on my local environment using both XAMP/PC and MAMP/MAC.
When I uploaded it to my host it does work, however the CRUD values don’t populate when it the for each loop is specified. I concatenated the mysql_error(); to explain why this is not working on my host.
On line 34 in logincrud/main.php:
The code from the table in main.php:
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Number</th>
<th>Explanation</th>
<th>Date Accured</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
include 'database.php';
$pdo = Database::connect();
$sql = 'SELECT * FROM saftey ORDER BY id DESC';
foreach (($sql) as $row) {
echo '<tr>';
echo '<td>'. $row['ins_n'] . '</td>';
echo '<td>'. $row['explanation'] . '</td>';
echo '<td>'. $row['date'] . '</td>';
echo '<td width=250>';
echo '<a class="btn" href="read.php?id='.$row['id'].'">Read</a>';
echo ' ';
echo '<a class="btn btn-success" href="update.php?id='.$row['id'].'">Update</a>';
echo ' ';
echo '<a class="btn btn-danger" href="delete.php?id='.$row['id'].'">Delete</a>';
echo '</td>';
echo '</tr>';
}
Database::disconnect();
?>
</tbody>
</table>
The Add, Update, and Delete works on the host as I can see the records from the safety table on myphpadmin. The login/logoff is from a completely different table. Again, the local environment works with no issues.
I opened a help ticket with my host provider, but all I received is they do not troubleshoot Applications.
I have been looking for solutions for a few weeks and all I couldn’t find a solution. In the Chrome browser the console states the error: hp:1 Failed to load resource: the server responded with a status of 500 ()" Server issue? Aware of SQL Injection problems.
I uploaded a GITHUB project if it helps.
Thank you in advance.