jimfog Posted March 10, 2015 Share Posted March 10, 2015 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 More sharing options...
justsomeguy Posted March 10, 2015 Share Posted March 10, 2015 http://php.net/manual/en/function.error-log.php Link to comment Share on other sites More sharing options...
jimfog Posted March 11, 2015 Author Share Posted March 11, 2015 http://php.net/manual/en/function.error-log.php 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 More sharing options...
justsomeguy Posted March 11, 2015 Share Posted March 11, 2015 I've never tried using error_log to send an email, but you probably need to give it all of the usual email headers. Link to comment Share on other sites More sharing options...
jimfog Posted March 11, 2015 Author Share Posted March 11, 2015 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 More sharing options...
thescientist Posted March 12, 2015 Share Posted March 12, 2015 send an email and include the error message as the body Link to comment Share on other sites More sharing options...
jimfog Posted March 12, 2015 Author Share Posted March 12, 2015 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 More sharing options...
westman Posted March 16, 2015 Share Posted March 16, 2015 $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 More sharing options...
Ingolme Posted March 16, 2015 Share Posted March 16, 2015 $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 More sharing options...
westman Posted March 16, 2015 Share Posted March 16, 2015 He what'd to know how to send an email. I helped with code. you are welcome Link to comment Share on other sites More sharing options...
thescientist Posted March 17, 2015 Share Posted March 17, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now