call a function in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nma
    New Member
    • Aug 2007
    • 93

    call a function in PHP

    Hi
    there is an error when I want to call a funcion. What is wrong here?How should I write php code inside this function to return an box to say notes deleted already?

    Thanks

    nma


    [PHP]

    <?php
    function DeleteEventNote s($noteID){
    $noteID = (int) $_GET['noteID'];
    $db->query("DELET E FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
    echo ("Notes Deleted");//how should I return an box to say notes deleted?
    }
    ?>

    [/PHP]



    [HTML]
    .......
    <td width="200" align="left" valign="top" class="infoDele teText"><?php echo $delete = DeleteEventNote s( $movieDelete->noteID );?><br/></td>
    ...
    [/HTML]
  • rpnew
    New Member
    • Aug 2007
    • 189

    #2
    Originally posted by nma
    Hi
    there is an error when I want to call a funcion. What is wrong here?How should I write php code inside this function to return an box to say notes deleted already?

    Thanks

    nma


    [PHP]

    <?php
    function DeleteEventNote s($noteID){
    $noteID = (int) $_GET['noteID'];
    $db->query("DELET E FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
    echo ("Notes Deleted");

    }
    ?>

    [/PHP]



    [HTML]
    .......
    <td width="200" align="left" valign="top" class="infoDele teText"><?php echo $delete = DeleteEventNote s( $movieDelete->noteID );?><br/></td>
    ...
    [/HTML]
    Hi,

    What do you exactly mean by this "how should I return an box to say notes deleted?"

    What did i understand from this is...... you want to return a message to the variable from which you are calling your function... is it right?

    If yes then use return instead of echo like following...... ...
    [PHP]
    function DeleteEventNote s($noteID){
    $noteID = (int) $_GET['noteID'];
    $db->query("DELET E FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
    return("Notes Deleted");
    }
    [/PHP]

    If you want something else then post back with your query....
    Regards,
    RP

    Comment

    • MarkoKlacar
      Recognized Expert Contributor
      • Aug 2007
      • 296

      #3
      Hi,

      You want a confirmation of some sort to pop up?
      Or am I way of base..?

      Originally posted by nma
      Hi
      there is an error when I want to call a funcion. What is wrong here?How should I write php code inside this function to return an box to say notes deleted already?

      Thanks

      nma


      [PHP]

      <?php
      function DeleteEventNote s($noteID){
      $noteID = (int) $_GET['noteID'];
      $db->query("DELET E FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
      echo ("Notes Deleted");//how should I return an box to say notes deleted?
      }
      ?>

      [/PHP]



      [HTML]
      .......
      <td width="200" align="left" valign="top" class="infoDele teText"><?php echo $delete = DeleteEventNote s( $movieDelete->noteID );?><br/></td>
      ...
      [/HTML]

      Comment

      • nma
        New Member
        • Aug 2007
        • 93

        #4
        Originally posted by MarkoKlacar
        Hi,

        You want a confirmation of some sort to pop up?
        Or am I way of base..?
        the error is below

        Notice: Undefined variable: db in C:\..\confirmDe lete.php on line 30

        Fatal error: Call to a member function query() on a non-object in C:\htdocs\..\co nfirmDelete.php on line 30


        [HTML]

        .....
        <tr>
        <td width="194" align="left" valign="top" class="infoDele teText"><?php echo $movieTitle;?></td>
        <td width="291" align="left" valign="top" class="infoDele teText"><?php echo $movieDelete->noteText;?></td>
        <td width="193" align="left" valign="top" class="infoDele teText"><?php echo $movieDelete->noteDate;?></td>
        <td width="200" align="left" valign="top" class="infoDele teText"><?php echo $delete = DeleteEventNote s( $movieDelete->noteID );?><br/></td>

        </tr>

        [/HTML]

        the functions..

        [PHP]
        <?php
        function DeleteEventNote s($noteID){
        $noteID = (int) $_GET['noteID'];
        $db->query("DELET E FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
        return("Notes Deleted");
        }
        ?>

        [/PHP]

        I want a like popup box appear once user click at delete word or button and then return to the current window. Should I also include include_once('. ./ez_sql.php'); inside the function.

        Comment

        Working...