Jump to content

cr125jb

New Members
  • Posts

    5
  • Joined

  • Last visited

cr125jb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. for my cron job, i had to put /usr/bin/php 0 0 * * * /usr/bin/php /path/email.php
  2. Thanks Barand! And thanks everyone for helping me with this script. Works like a charm!
  3. Thanks for all of the replies. I'm almost there and just need a little help. Here's what I have so far... My Crontab file has: 0 0 * * * username /path/email.php My PHP file contains: <?php // database connection mysqli_connect is the mysql command then followed by ('IP', 'user', 'pass', 'database') $dbc = mysqli_connect('IP', 'user', 'pass', 'database') or die('Error connecting to MySQL server.'); // MySQL code to grab the fields I need and only grab the dates that are 30 days from expiration. Tested in navicat and this code does exactly what is expected $sql = 'SELECT TABLE1.EMP_EMAIL, TABLE1.EMP_FULLNAME, TABLE2.LIS_DATE_EXP, TABLE2.CL_FNAME, TABLE2.CL_LNAME, TABLE2.LIS_NAME FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.EMP_FULLNAME = TABLE2.EMP_ID WHERE LIS_DATE_EXP = DATE_ADD(CURDATE(),INTERVAL 30 DAY)'; $result = mysqli_query ($dbc, $sql); // Define the variables and columns (loop the array) while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $email = $row["TABLE1.EMP_EMAIL"]; $fullname = $row["TABLE1.EMP_FULLNAME"]; $name = $row["TABLE2.LIS_NAME"]; $date_exp = $row["TABLE2.LIS_DATE_EXP"]; $cl_fname = $row["TABLE2.CL_FNAME"]; $cl_lname = $row["TABLE2.CL_LNAME"]; // Mail code to e-mail based on the records pulled from above code. Hoping that the syntax is correct. $to = "email@yahoo.com, " . $email . " "; $subject = "Listing " . $name . " is about to expire!"; $message = "The Listing " . $name . " is going to expire on " . $date_exp . ". Please contact " . $cl_fname . " " . $cl_lname . " and extend the listing agreement."; $from = "email@yahoo.com"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); } echo "Mail Sent."; ?> The problem with my syntax is that I get an e-mail for each listing that falls in the 30 days away category, but I'm not getting the field information. So I don't get any of the information from the database. For instance below is the e-mail I get. The Listing is going to expire on . Please contact and extend the listing agreement.
  4. My database is setup in 'date' format (YYYY-MM-DD). I'm working on the query but I'm having a little trouble understanding grabbing information from two tables in the same databases. For instances I have my table that houses listing information which is where the expiration date is. I then have another table where my agent information is which houses the agents e-mail addresses. How do I write a script/query to access some information from one table, and some information from another? Then send an e-mail using the e-mail address in the agent table? I was considering just create a view table that houses only the information I want in one place, but I would like to know how to get information from two tables in one query.
  5. Quick overview, I work for a Real Estate Company. I created a PHP website using PHP Runner to organize all of our current listings. This site is where my agents login and add new listings. Upon adding a new record, e-mails are sent to Marketing and Administration to begin their marketing prcoess to create flyers and add the listings to websties. So what I'm trying to figure out is how to send a reminder e-mail 1 month before the listing is expired. I have a field the agents fill out called "LIS_DATE_EXP" or expiration date. My schema is very basic. I have a V_LIS table that is for the listing information. I have an V_EMP table that contains the data of the users that will access the site. Name, E-mail, Password, etc. I need to create a php file that will call the LIS_DATE_EXP of each record of the V_LIS table, check to see if it's 1 month before that date. IF it is, then send an e-mail to the agent using the e-mail in the V_EMP table and send an e-mail to me so I can follow up. I'm not sure what the best way to go about this is. I could create a view/join table that contains only a few fields specifically for this function but I don't know. I've read that I need to create a cron job that will run a script every day, but I'm a novice at web coding and I couldn't get what I needed accomplished. I'm a network admin and I'm trying to move away from microsoft and join the open source world. I'm currently setting up Ubuntu servers to house websites and a mapping system we use for our company. This web stuff is a new experience for me =] Thanks for the help in advance
×
×
  • 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.