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
[syntax=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 table[/syntax]
and here is the code:
[syntax=php]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';
?>[/syntax]
ive tried to find the error but cant see it anywhere so any help would be great! Thank you
Connor
Blog Tutorial - Invalid Post ID - blog-read.php
-
- Posts: 1
- Joined: Wed Apr 18, 2012 3:21 pm
Re: Blog Tutorial - Invalid Post ID - blog-read.php
You definitely have a advert_id parameter in the URL ? I can't see anything wrong right away so it could be that you have made a typo with a variable name somewhere and the problem is being hidden.
If you set your error_reporting config option to E_ALL it should shoe up and problems with variables that are being used that do not have a value.
If you set your error_reporting config option to E_ALL it should shoe up and problems with variables that are being used that do not have a value.