By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

call a function in PHP

P: 93
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 DeleteEventNotes($noteID){
$noteID = (int) $_GET['noteID'];
$db->query("DELETE 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="infoDeleteText"><?php echo $delete = DeleteEventNotes( $movieDelete->noteID );?><br/></td>
...
[/HTML]
Feb 7 '08 #1
Share this Question
Share on Google+
3 Replies


rpnew
100+
P: 188
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 DeleteEventNotes($noteID){
$noteID = (int) $_GET['noteID'];
$db->query("DELETE FROM EventNotes where userID = " . $_SESSION['user']->userID ." and noteID = $noteID ");
echo ("Notes Deleted");

}
?>

[/PHP]



[HTML]
.......
<td width="200" align="left" valign="top" class="infoDeleteText"><?php echo $delete = DeleteEventNotes( $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 DeleteEventNotes($noteID){
$noteID = (int) $_GET['noteID'];
$db->query("DELETE 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
Feb 7 '08 #2

MarkoKlacar
Expert 100+
P: 296
Hi,

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

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 DeleteEventNotes($noteID){
$noteID = (int) $_GET['noteID'];
$db->query("DELETE 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="infoDeleteText"><?php echo $delete = DeleteEventNotes( $movieDelete->noteID );?><br/></td>
...
[/HTML]
Feb 7 '08 #3

P: 93
nma
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:\..\confirmDelete.php on line 30

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


[HTML]

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

</tr>

[/HTML]

the functions..

[PHP]
<?php
function DeleteEventNotes($noteID){
$noteID = (int) $_GET['noteID'];
$db->query("DELETE 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.
Feb 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.