SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: if else problem
-
Apr 25, 2007, 13:09 #1
- Join Date
- Dec 2006
- Posts
- 430
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if else problem
Hi Guys,
Sorry, this problem is dead basic i bet but i can't figure it out! basically when editing blog posts, if the user has no entries to edit then "sorry no entries exhist at present" but if the y do exhist then echo them out , i did the usual if/else but it isn't working heres the code:
PHP Code:<?php
// Get the users id...//////////////////////////////////////////////////////////////
$id = $_GET['id'];
// Delete the blog post from the site...////////////////////////////////////////////
if($_GET['action']=='DelCom') {
mysql_query("DELETE FROM member_comments WHERE id='$id'");
echo "<p>The Blog Post Has Been Deleted Successfully <a href=\"javascript: history.go(-1)\">Go Back</a></p>";
}
// Make a query to retrieve the comments.../////////////////////////////////////////
$query2 = "SELECT * FROM member_comments WHERE mid='$id'";
$result = @mysql_query($query2) or die(mysql_error());
// No commenst on blog...///////////////////////////////////////////////////////////
if($mysql_num_rows == 0) {
echo "<p>Sorry, You Have No Posts To Edit Yet!</p>";
} else {
// display the profile comments in a loop...////////////////////////////////////////
while($row = mysql_fetch_array($result)) {
$post = $row['comments'];
$post_id = $row['id'];
echo "<table width=\"100%\" border=\"1\" bordercolor=\"black\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td width=\"20%\" bgcolor=\"#E2E2E2\"><p>Blog Post: $post_id</td><td width=\"70%\" bgcolor=\"#E2E2E2\"><p>$post</td><td bgcolor=\"#E2E2E2\"><p><a href=\"edit_blog.php?action=DelCom&id=$post_id\" onclick=\"return confirm('Are You Sure You Want To Delete This Blog Post?');\">Delete</a>/<a href=\"edit_blog_comments.php?id=$post_id\">Edit</a></td>
</tr>
</table><br />";
}
}
?>
Graham
-
Apr 25, 2007, 13:28 #2
- Join Date
- Nov 2005
- Location
- The Netherlands
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try removing the @ in front of mysql_query and see what the error is?
If any.
Taking over the web one pixel at a time.
Currently working @ CodeCreators
-
Apr 25, 2007, 13:37 #3
- Join Date
- Dec 2006
- Posts
- 430
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Mate
error is:
PHP Code:Fatal error: Function name must be a string in C:\Program Files\wamp\www\WEBSITES\www.cdm-remodelled.com\edit_blog.php on line 51
PHP Code:<p>Edit The Comments On Your Profile Blog Below:</p>
<?php
// Get the users id...//////////////////////////////////////////////////////////////
$id = $_GET['id'];
// Delete the blog post from the site...////////////////////////////////////////////
if($_GET['action']=='DelCom') {
mysql_query("DELETE FROM member_comments WHERE id='$id'");
echo "<p>The Blog Post Has Been Deleted Successfully <a href=\"javascript: history.go(-1)\">Go Back</a></p>";
}
// Make a query to retrieve the comments.../////////////////////////////////////////
$query2 = "SELECT * FROM member_comments WHERE mid='$id'";
$result = mysql_query($query2) or die(mysql_error());
// No commenst on blog...///////////////////////////////////////////////////////////
if ($mysql_num_rows($result)==0) {
echo '<p>Sorry, You Have No Posts To Edit Yet!</p>';
} else {
// display the profile comments in a loop...////////////////////////////////////////
while($row = mysql_fetch_array($result)) {
$post = $row['comments'];
$post_id = $row['id'];
echo "<table width=\"100%\" border=\"1\" bordercolor=\"black\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td width=\"20%\" bgcolor=\"#E2E2E2\"><p>Blog Post: $post_id</td><td width=\"70%\" bgcolor=\"#E2E2E2\"><p>$post</td><td bgcolor=\"#E2E2E2\"><p><a href=\"edit_blog.php?action=DelCom&id=$post_id\" onclick=\"return confirm('Are You Sure You Want To Delete This Blog Post?');\">Delete</a>/<a href=\"edit_blog_comments.php?id=$post_id\">Edit</a></td>
</tr>
</table><br />";
}
}
?>
Graham
-
Apr 25, 2007, 13:40 #4
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
evening Graham, whats on line 51?
Mike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 25, 2007, 13:58 #5
- Join Date
- Dec 2006
- Posts
- 430
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey SpizeZ,
line 51 starts from the first line below down:
PHP Code:if ($mysql_num_rows($result)==0) {
echo '<p>Sorry, You Have No Posts To Edit Yet!</p>';
} else {
// display the profile comments in a loop...////////////////////////////////////////
while($row = mysql_fetch_array($result)) {
$post = $row['comments'];
$post_id = $row['id'];
echo "<table width=\"100%\" border=\"1\" bordercolor=\"black\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td width=\"20%\" bgcolor=\"#E2E2E2\"><p>Blog Post: $post_id</td><td width=\"70%\" bgcolor=\"#E2E2E2\"><p>$post</td><td bgcolor=\"#E2E2E2\"><p><a href=\"edit_blog.php?action=DelCom&id=$post_id\" onclick=\"return confirm('Are You Sure You Want To Delete This Blog Post?');\">Delete</a>/<a href=\"edit_blog_comments.php?id=$post_id\">Edit</a></td>
</tr>
</table><br />";
}
}
?>
Graham
-
Apr 25, 2007, 14:00 #6
- Join Date
- Jul 2006
- Location
- Ontario, Canada
- Posts
- 424
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:if (mysql_num_rows($result)==0) {
-
Apr 25, 2007, 14:03 #7
-
Apr 25, 2007, 14:04 #8
- Join Date
- Dec 2006
- Posts
- 430
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
damn so it was lol
once again thanks for the help guys, if you's ever need help with pharamacy related issues give me a shout lol
Graham
-
Apr 25, 2007, 14:07 #9
- Join Date
- Dec 2006
- Posts
- 430
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
lol ah another spelling mistake lol
-
Apr 25, 2007, 14:27 #10
- Join Date
- Mar 2007
- Posts
- 196
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's ok graham23s, we are all guilty of making a spelling error here and there, especially when we are posting like crazy.
Kayzio - We don't hesitate, we accelerate.
Bookmarks