Blog Tutorial - Invalid Post ID - blog-read.php
Posted: Wed Apr 18, 2012 3:26 pm
Hi i was wondering if you could help! i keep getting the invalid post id when i got to click on blog! i followed the tutorials and changed the variables to fit my website. However it doesnt appear to be working:
advert.func.php
ive tried to find the error but cant see it anywhere so any help would be great! Thank you
Connor
advert.func.php
function valid_ad_id($advert_id) { $advert_id = (int)$advert_id; $total = mysql_query("SELECT COUNT(`advert_id`) FROM `adverts` WHERE `advert_id`={$advert_id}"); $total = mysql_result($total, 0); if ($total != 1) { return false; } else { return true; } } //checks if advert id is within the tableand here is the code:
if (isset($_GET['advert_id']) === false || valid_ad_id($_GET['advert_id']) === false){ echo 'Invalid Email.'; }else { $advert = get_advert($_GET['advert_id']); ?> <h1><?php echo $advert['title']; ?></h1> <h2>From: <?php echo $advert['email']; ?> on <?php echo $advert['date']; ?> (<?php echo count($advert['comments']); ?> comments)</h2> <hr /> <p><?php echo $advert['body']; ?></p> <hr /> <?php foreach ($advert['comments'] as $comment) { ?> <h1>From: <?php echo $comment['email']; ?> on <?php echo $comment['date']; ?></h1> <p><?php echo $comment['body']; ?></p> <hr /> <?php } ?> <form action="" method="POST"> <div> <label for="email">Email</label> <input type="text" name="email" id="email" /> <div> <textarea name="body" rows="10" cols="90"></textarea> </div> <div> <input type="submit" value="Reply" /> </div> </form> <?php } include 'template/footer.php'; ?>
ive tried to find the error but cant see it anywhere so any help would be great! Thank you
Connor