This is the code I am using but it keeps giving me this error:
Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':' at line 1
I have tried a easier alternative to doing what I want but I got more errors that left me more confused than this piece of code. Any help will be greatly appreciated!
$query = "SELECT user_id, track_name, contents FROM track where user_id = $uid";
try
{
// These two statements run the query against your database table.
$stmt = $db->prepare($query);
$stmt->execute(array());
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}
// Finally, we can retrieve all of the found rows into an array using fetchAll
$rows = $stmt->fetchAll();
?>
<p> Welcome to tracks :D </p> <table style="padding-bottom:30px; padding-left:10px;s">
<tr>
<th>Track Name</th>
<th> Contents</th>
</tr>
<?php foreach($rows as $row): ?>
<tr>
<td><?php echo htmlentities($row['track_name'], ENT_QUOTES, 'UTF-8'); ?></td>
<td> <?php echo htmlentities($row['contents'], ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
<?php endforeach; ?>
</table>