Jump to content

Recommended Posts

hi all, im tryign to create error notification if my mysql database goes down

 

i have an errorpage set up to email me if the mysql goes down but i only want to be emailed once not everytime someone vists the site and gets redirected to the error page

 

so someone goes to mysite.com mysql is down so goes to mysite.com/errorpage.php?mysql

 

now i want to run a function that emails me and i only want to be emailed once, anyone know how i could achieve this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/157823-run-function-only-first-page-visit/
Share on other sites

You would need to store a value on your server (in a file) or you could simply just create and delete a file to serve as a flag. You would either set the value or create the file when the first failure email is sent. The code would then check for the value or the existance of the file and not send further emails.

 

You would then need to clear the value or delete the file upon a successful connection to the database server.

yeah i forgot to mention id need to reset the value after the problem has been rectified

 

can anyone sample me some code that will create a textfile or whatever file and put a 1 in it?

 

then ill either figure out a code to update it to a 0 or ill change the result back to 0

 

then i caould run an if statement to check for a 1 if results is a 1 email me :)

 

Thanks

 

also would this file need chmod permissons? and would giving this file permissons, leave a security vunreability?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.