html - PHP not fetching images from my server folder -
i have code supposed fetch image server , display on html. images encrypted in md5 , when uploading them server there no field in table stores names of images. therefore calling image using primary key in table image.
here code:
<?php // connection string constants define('dsn', 'mysql:dbname=mydbname;host=localhost'); define('user', 'myuser2015'); define('password', 'mypwd2015'); // pdo instance creation $pdo = new pdo(dsn, user, password); // query preparation $stmt = $pdo->query(" select title, introtext, id, created, created_by, catid mytbl_items limit 4 "); // fetching results $result = $stmt->fetchall(pdo::fetch_assoc); // if returns 0 means no records present echo count($result) . "\n"; // loop should print valid table foreach ($result $index => $row) { if ($index == 0) echo '<div>'; echo <<<htm <img style='width:100%; height:200px;' echo "../media/k2/items/cache/".md5("image".{$row['id']})."_xl.jpg"; <span class="post-date">{$row['created']}</span> <h2 class="blog-post-title">{$row['title']}</h2> <p> {$row['introtext']} </p> <p> <a href='read.php?id={$row['id']}'><input type="button" value="read more" /></a> </p></br> <div class="blog-meta"> <img src="img/icons/logo.png" alt="avatar" /> <h4 class="blog-meta-author">{$row['created_by']}</h4> <span>category: {$row['catid']}</span> </div> htm; if ($index == (count($result)-1))echo '</div>'; }
what mistake making code supposed fetch image? line
img style='width:100%; height:200px;' echo "../media/k2/items/cache/".md5("image".{$row['id']})."_xl.jpg";
remove second echo
here/nowdoc. started echo
ing in
echo <<<htm
Comments
Post a Comment