Jump to content

drranch

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

drranch's Achievements

Member

Member (2/5)

0

Reputation

  1. need some assist... the script below sends out two emails and I cant seem to find out why...Im semi new to php and Im thinking Im missing something... <?php function dprint_r($array) { echo "<pre>"; print_r($array); echo "</pre>"; die(); } function get_status($status_code) { switch ($status_code) { case 0: $status = "New"; break; case 1: $status = "Assigned"; break; case 2: $status = "Work In Progress"; break; case 3: $status = "Pending"; break; case 4: $status = "Resolved"; break; case 5: $status = "Closed"; break; default: $status = "??????"; } return $status; } function get_report() { global $holidays, $unix_now, $unix_morning; switch(date('l', time())) { case 'Monday': if (in_array($curdate, $holidays)) $report = "none"; elseif ($unix_now < $unix_morning) $report = "weekend"; elseif ($unix_now > $unix_morning) $report = "daily"; break; case 'Tuesday': if (in_array($yesterday, $holidays)) $report = "weekend"; else $report = "daily"; break; case 'Wednesday': case 'Thursday': case 'Friday': $report = "daily"; break; case 'Saturday': case 'Sunday': $report = "none"; break; default: die('Invalid day'); } return $report; } require_once('include.php'); require_once('Spreadsheet/Excel/Writer.php'); require_once('email.class.php'); $xls =& new Spreadsheet_Excel_Writer('daily.xls'); $sheet =& $xls->addWorksheet('Sheet 1'); $email_to = 'me@myemail.com; $email_from = 'your<me@youremail.com>'; $email_subject = 'Daily report for ' . date('m/d/Y'); $email = new Email($email_to, $email_from, $email_subject); $holidays = array("1/1/2007", "1/15/2007", "2/19/2007", "5/28/2007", "7/4/2007", "9/3/2007", "11/22/2007", "11/23/2007", "1/1/2008"); $fields = array('Case ID', 'Requestor', 'New.TIME', 'Summary', 'Status', 'Assigned Group'); $unix_now = time(); $curtime = date('H:i:s'); $curdate = date('m/d/Y'); $yesterday = date('m/d/Y', strtotime('yesterday')); $curmorning = "$curdate 09:30:00"; $midnight = "$curdate 00:00:00"; $unix_morning = strtotime($curmorning); $unix_midnight = strtotime($midnight); $report = get_report(); switch($report) { case 'daily': $time = strtotime('Yesterday 6:30am'); $sqldate = "AND sh.new_time >= $time"; break; case 'weekend': $time = strtotime('Last Friday 6:30am'); $sqldate = "AND sh.new_time >= $time"; break; default: die('No report generated'); } $sql = "SELECT h.case_id_, h.requester_name_, sh.new_time, h.summary, h.status, h.assigned_to_group_ FROM hpd_helpdesk AS h, sh_hpd_helpdesk as sh WHERE h.priority = 2 AND sh.case_id_ = h.case_id_ $sqldate ORDER BY h.case_id_ ASC"; $rs = $db->Execute($sql); $colheading =& $xls->addFormat(); $colheading->setBold(); $colheading->setAlign('center'); $sheet->write(0, 0, 'Daily'); $text[] = 'Daily High Ticket Report'; $sheet->write(1, 0, '1234567'); $text[] = '1234567'; $sheet->write(2, 0, '1234567'); $text[] = '1234567'; $sheet->writeRow(4, 0, $fields, $colheading); $text[] = implode("\t", $fields); $rowcount = 5; $rowformat =& $xls->addFormat(); $rowformat->setTextWrap(true); //die(print_r($rs)); while ($row = $rs->FetchRow()) { $row['status'] = get_status($row['status']); $row['new_time'] = date('m/d/Y H:i', $row['new_time']); $sheet->setColumn(0, 0, 20); $sheet->setColumn(0, 1, 20); $sheet->setColumn(0, 2, 20); $sheet->setColumn(0, 3, 40); $sheet->setColumn(0, 4, 15); $sheet->setColumn(0, 5, 20); $sheet->writeRow($rowcount++, 0, $row, $rowformat); $text[] = implode("\t", $row); } // save the text file $fp = fopen('daily_high_tickets.txt', 'w'); foreach($text as $row) { $row .= "\r\n"; fwrite($fp, $row); } // save the xls file $xls->close(); // attach the files and send the email $email->Attach('daily.xls', 'application/vnd.ms-excel'); $email->Attach('daily.txt', 'text/plain'); $email->Send(); ?>
  2. Is there antivirus running on the server? If so check to makes sure it isn't blocking it from getting written to.
  3. I have a MYSQL query that pulls appointment data from my database and sends an email to the people who have appointments. However, if there are several appointments for one person each appointment is sent in a different email. How do I get for each user with several appointments one email sent with all appointments in the single email. $rsnotifier = mysql_query($query_notifier, $database); while($row_rsnotifier = mysql_fetch_assoc($rsnotifier)) { $email_address = $row_rsnotifier["email_address"]; $subject = "Appointment Reminder"; $message = "<html> <head> <title>My Calendar Appointment</title> </head> <body background='http://www.name.com/images/bkrnd.jpg'> <?php do { ?> <div>Hello,<br> Its time for {$row_rsnotifier['appdesc']} - {$row_rsnotifier['follow_up_date']}</div> <?php } while ($row_rsnotifier = mysql_fetch_assoc($rsnotifier));?> </body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'From: My Appointment Reminder <admin@name.com>' . "\r\n";
  4. drranch

    HELP

    If I understand you right you only want to know how to query and count how many times the word "very Good" is in all of the three columns... "SELECT column1, column2, columm3, COUNT(*) AS total FROM backup WHERE StartDate AND EndDate BETWEEN '2006-12-01' AND '2007-12-31' AND column1 = 'Very Good' AND column2=Very Good AND column3=Very Good GROUP BY column1")"
  5. What is your current syntax. Reading syntax helps me to better understand what your looking for.
  6. My best guess is something is blocking the file from being written to. Check the permissions on the folder to make sure they are read/write and if they are find out what applications are running on the server that could be blocking access for writing to the file. If you runnin through a hosted server call support and work with them in clearing temp files on the server.
  7. Try this out... SELECT * FROM tablename ORDER BY id DESC LIMIT 1 HA your not the only one with out a life.
  8. Are those all the columns in your bookings table? I see in your syntax you have in the sub query "SELECT 'bookings', ...... If you don't have a colum called bookings in your table then your script should be catching that saying that there isn't a recognized column. "SELECT distinct(departicao), depart FROM flights WHERE NOT EXISTS(Select ID FROM Bookings WHERE date = $date AND bookings.flightid=flights.id) AND $day=1 GROUP BY departicao" Just a guess I'm no expert, but learning along with everyone else.
  9. will you be running it every hour manually? If not you will need to set the MYSQL/PHP script up with cron to run every hour.
  10. you must first create a database Then create the tables for the database if your using a hosting service you can create the database through them if you have an account that allows your ability to create the database. Then you can use the code you noted in your posting to create the table. The code you show above will create a table called 'users'
  11. Is your site running on a hosted server? If so you will need to check to see if they have this option for you You would build the MYSQL/PHP scripting and then set up the cron option to run the MYSQL/PHP script. Using the cron option through your provider will let you run the script at a certain time and day.
  12. It sounds like you are trying to "concatenate" two strings together... UPDATE table SET name=concat(name, smith)
  13. The backslash is an escape charater in MYSQL and that was the reason for the error. Using the new one you built is fine since using mysql escape string is escaping the backslash escape character. You could have used two back slashes on the orginal script, since they would have represented a single backslash and not recognized by MYSQL or PHP as an escape character of a single back slash. Using mysql_real_escape_String() around each variable prevents SQL injections from occuring by prepending backslashes to the following characters \x00, \n, \r, \, '," and \x1a This function should always be used with few exceptions to make data safe before sending a query to MYSQL
  14. drranch

    HELP

    Show us your insert statement for the radio buttons
×
×
  • 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.