Function works exactly once?
| From: | David VanHorn | Date: | Fri, 30 Jun 2000 00:03:09 +0000 |
| Subject: | Function works exactly once? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3926@lists.php.net to get a copy of this message | ||
I have a logging function in a separate file,
It's called like this below, and <ALWAYS> works the first time.
The second time I call it, it always fails, "Can't INSERT Action Log Record"
This happens, even if I clone the same call that worked, rather than three different ones, as intended.
Why would it only go once?
#Here' s how I call the function
require ("../PHP/do_action_log.php");
$Log_Text = ("Test for log file");
do_action_log($Log_Text); #This one always works
do_action_log($Log_Text); #This one always fails
do_action_log($Log_Text); #This one never gets a chance.
Here's the function itself, in the PHP subdir, in a file called "do_action_log.php"
<?
#Event logging function
function do_action_log ($Log_Text) {
$Debug = true;
#Handle any calls that give null log_text
if (!isset ($Log_Text)) {$Log_Text = "Mysterious entry";}
#Keep it parseable
$Log_Text =(strtoupper(trim($Log_Text)));#Generate timestamp $Timestamp = gmdate("m-d-Y h:i:s"); #Display if debug is enabled if ($Debug) {echo("Logging: ".$Timestamp.",".$Log_Text);} MySQL_db_query('database',"INSERT INTO top_action_log VALUES('$Timestamp','$Log_Text')") or die ("Can't INSERT Action Log Record"); #Display if debug is enabled if ($Debug) {echo("Logged ok <P>");} }#End of function ?> -- www.SpamWhack.com A pre-emptive strike against spam A tornado is a lady whose skirts you do NOT want to look up! Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9