php - unexpected end of file and when solved doesn't work -
this piece of code giving me unexpected end of file. don't know what's wrong. when change : @ end issue of error gone code stops working. no longer fetches me data. when copy code jsfiddle closing </section>
tag , closing </div>
tag, second last in red color. idea why? tags in wrong order?
<?php while ($r = $q->fetch()): ?>
here full code i'm working on if interested or got clues.
<section id="portfolio" class="two"> <div class="container"> <header> <h2>latest answers</h2> </header> <?php require_once 'dbconfig.php'; try { $conn = new pdo("mysql:host=$host;dbname=$dbname", $username, $password); echo "connected $dbname @ $host successfully."; $sql = "select * as_questions answer not null , answer != ''"; $q = $conn->query($sql); $q->setfetchmode(pdo::fetch_assoc); } catch (pdoexception $pe) { die("could not connect database $dbname :" . $pe->getmessage()); } ?> <table> <?php while ($r = $q->fetch()): ?> <div class="span3 tiny"> <div class="pricing-table-header-tiny"> <h1 id="h1q"><?php echo htmlspecialchars($r['question']);?></h1> </div> <div> <div class="pricing-table-features"> <p id="dassp2"> <?php echo htmlspecialchars($r['answer'])?> </p> </div> <div> <p id="dassp">answered by: <?php echo htmlspecialchars($r['doctor'])?> </p> </div> </div> </div> </div> <div id="qref"> <a href="#" id="s">more answers</a> </div> </section>
while (expr): statement ... endwhile;
you need close loop - more info here http://php.net/manual/en/control-structures.while.php
Comments
Post a Comment