SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: if else problem

Hybrid View

  1. #1
    SitePoint Evangelist
    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 />"
    ;         
         }
      }
    ?>
    thanks for the help guys

    Graham

  2. #2
    SitePoint Addict Kokos's Avatar
    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

  3. #3
    SitePoint Evangelist
    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 
    code now is:

    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 />"
    ;         
         }
      }
    ?>
    thanks mate

    Graham

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    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.....

  5. #5
    SitePoint Evangelist
    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 />"
    ;         
        }
     }
    ?> 
    cheers mate

    Graham

  6. #6
    Grumpy Minimalist
    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) { 

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by graham23s View Post
    Hey SpizeZ,
    close enough!
    oh and what Tarh said
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Evangelist
    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

  9. #9
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol ah another spelling mistake lol

  10. #10
    SitePoint Zealot
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •