Re: Function works exactly once?

From: Date: Fri, 30 Jun 2000 01:36:37 +0000
Subject: Re: Function works exactly once?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3937@lists.php.net to get a copy of this message
On 29 Jun, David VanHorn wrote: > > 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 > ?> Use mysql_error() where the problem occurs to get any error message that mysql is returning. This will often give you a clue as to what's wrong. Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#3937) next »