Hi I wounder how i can work around this error when i delete
a post...
i get this error becuse the post dosent exist after i delete it but thats i the only way i can get i to delete the post but then i get the error note tha says tah the post dosen exist.. anoying
bu is there a way to get around it sow i can view the post that exist after i delete the post wiht out the error or a refres button
here is the error not
Warning: mysql_fetch_array(): 7 is not a valid MySQL result resource in C:\Apache Group\Apache2\htdocs\newspost\newspostview.php on line 120
Warning: mysql_num_rows(): 7 is not a valid MySQL result resource in C:\Apache Group\Apache2\htdocs\newspost\newspostview.php on line 172
the code i use
<?php
require( './functions.php');
$post_query = mysql_query("SELECT * FROM newspost ORDER BY postorderstamp") or die (mysql_error());
while ($post = mysql_fetch_array($post_query)) {
?>
<h3 class="posticon"> Posted By: <?php echo $post['username'] ?></h3>
<h3 class="posttimeicon"> Post Time: <?php echo $post['postorderstamp'] ?></h3>
<h3 class="mailicon">
Mail to: <A HREF="mailto:<?php echo $post['Email'] ?>">
<?php echo $post['username'] ?></A></h3><br>
<div style="width: 91%;">
<form action="edit-newspost.php" style="margin:0px; float: left;">
<input type="hidden" name="postID" value="<?php echo $post['ID'] ?>">
<input type="submit" class="button" style="width: 90px; height: 20px;" align="center" value="Edit Your Post">
</form>
<?php
$username =$_SESSION["username"];
$action = $_POST["action"];
$password = $_SESSION['password'];
$postID = $_GET['postID'];
if ($action == "delete_two") {
$post_query = mysql_query("SELECT * FROM newspost WHERE (ID='$postID' AND username='$username' AND password='$password')") or die (mysql_error());
if (mysql_num_rows($post_query) != 1) {
showheader("UserName Error");
?>
<br><p><center>Incorrect Username, The post does not belong to you, You can not delete the post</center></p>
<?php
showfooter();
exit;
}
$post = mysql_fetch_array($post_query);
mysql_free_result($post_query);
deletepost();
$post['Post'] = ereg_replace("<br>", "", $post['Post']);
showheader("Post Successfully Deleted");
}
?>
<form action="<?php echo $PHP_SELF ?>?postID=<?php echo $post['ID'] ?>" method="POST" style="margin:0px; float: right;">
<INPUT TYPE="hidden" name="action" value="delete_two">
<input type="submit" class="button" style="width: 90px; height: 20px;" align="center" value="Delete Your Post">
</form >
</div>
_________________________________<br><br>
<?php echo $post['Post'] ?>
<br>_________________________________<br><br>
<?php
}
if (mysql_num_rows($post_query) < 1) {
}
?>
</FORM>