Reputation: 150
I want to GET my photo_id to load information about the photo from the database but i get an error with binding my parameter in the query. I also want to echo my 'foto_titel' in a textbox but it don't show it.
Thank you very much for your help
<?php
$fotonr = $_GET['fotoid'];
$stmt = $pdo->prepare('SELECT * FROM fotos WHERE foto_id = :fotonr');
$stmt->bindParam(':fotonr', $fotonr, PDO::PARAM_INT);
$stmt->execute(array($fotos));
$fotosArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($fotosArray as $row) {
echo $row['foto_titel'];
}
?>
<input id="naamfoto" name="naamfoto" value="WANT TO ECHO HERE" class="form-control input-md" type="text" required>
Upvotes: 1
Views: 52
Reputation: 150
I changed
$stmt->execute(array($fotos));
to
$stmt->execute();
And my full code:
<?php
$fotonr = $_GET['fotoid'];
$stmt = $pdo->prepare('SELECT * FROM fotos WHERE foto_id = :fotonr');
$stmt->bindParam(':fotonr', $fotonr, PDO::PARAM_INT);
$stmt->execute(array($fotos));
$fotosArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($fotosArray as $row) {
echo $row['foto_titel'];
}
?>
Upvotes: 1