Jump to content

logging


jimfog

Recommended Posts

If there is one thing I have not considered so far is logging.

 

So,first,take a look at this code:

if ($stmt = $connection->prepare('INSERT into  appoint_servi_chosen (app_ID,service_ID) VALUES( ?, ? )'))             {             $stmt->bind_param('ii',$lastid,$value);               $stmt->execute();             if($stmt->errno!==0)             {printf("Error-execution failed appoint_servi_chosen table: %s.n", $stmt->error);              return  false;             }             $stmt->close();             }             else             {printf("Error-prepare statement failed appoint_servi_chosen table: %s.n", $connection->error);              return  false;             }            }

there are 2 cases above where an error is printed in the browser.

I think that this code must be replaced by code that does logging but I have no idea from where to start.

Do you know any library for example?

Is there something else I need to consider?

Link to comment
Share on other sites

yes...this is what I was thinking...I have a question though.

Cause I want to write to a file and send an email I am calling error_log twice.like this:

$headers = 'Content-type: text/html; charset=iso-8859-1' . "rn"; error_log("error message for insert appt()-execution failed:".$stmt->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 3,"error_log.log");  error_log("error message for insert appt()-execution failed:".$stmt->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 1,"...@...r",$headers);            

Nonetheless....I do not get any email(which is hidden here for obvious reasons)...is there anything wrong with the syntax here?

If nothing is wrong with the syntax then there must be something wrong with my e-mail configuration in my local machine

Link to comment
Share on other sites

I've never tried using error_log to send an email, but you probably need to give it all of the usual email headers.

What do you use in order to send an email to notify about an error.

Link to comment
Share on other sites

send an email and include the error message as the body

I assume that mean using the ordinary php mail function.

Link to comment
Share on other sites

$to = "me@gmail.com";	$from = "admi@mysite.com";$subject = "error";$message = '<html>		<body bgcolor="#FFFFFF">		<br /><br />        Error: ' . $error_log . '		</body>		</html>';		// end of message		$headers = "From: $fromrn";		$headers .= "Content-type: text/htmlrn";		// Finally send the activation email to the member		mail($to, $subject, $message, $headers);

NOTE to the mods and admin.

It is ok to help with code from time to time it will not kill you to help in this way.

Link to comment
Share on other sites

$to = "me@gmail.com";	$from = "admi@mysite.com";$subject = "error";$message = '<html>		<body bgcolor="#FFFFFF">		<br /><br />        Error: ' . $error_log . '		</body>		</html>';		// end of message		$headers = "From: $fromrn";		$headers .= "Content-type: text/htmlrn";		// Finally send the activation email to the member		mail($to, $subject, $message, $headers);

NOTE to the mods and admin.

It is ok to help with code from time to time it will not kill you to help in this way.

 

 

I don't believe your response has anything to do with error logging, which is what is being discussed.

Link to comment
Share on other sites

mail function is fairly straightforward, I would have expected the OP to reply with questions about a specific implementation if he had any issues. We encourage people to try first with code. Also, some of us lose track of our time and the topics, we are volunteers after all.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...