MySQL / PHP code help.

I’m needing help with my family MySQL/PHP setup to work with cron commands and pull down selections.

I had this code written for me almost 3 years ago and it has been
working great. I’m hoping this is something not to difficult. If it is, I’ll have to close it.

I have zip file of the utils and templates that work with our database. If it will be easy enough to just change the code and not have to write the whole thing over that would be great. I did not see a way to attach a file.

I have included the section from the utils.php at the bottom were the array is. I can send the zip file if
it’s going to be needed.

DBase ------------------------------------------

Cron command will consist of send email or text message

          • mail -s ‘message’ user@phoneProvider < message

2.) Restrict user to add/edit/delete only 5 entry’s
(Allow me to change to allow more/less entries) simple changeable
in code is fine. (Make notation in code)

3.) I need to dump the database but only the cron_command and only
when a change has been made to the database. Checking once every 15 minutes with a cron should be fine.

I would like the dump to create a per user dump file but if that is to difficult or costly I can deal with it being dumped to one file.

4.) When the user brings up their entry I do not want the cron_command displayed. They won’t understand what that is and think something is wrong.

5.) I have friends/daughters in different time zones that will also be using this. Need it to detect their time zone and adjust the cron time for their area. If adding a state selection makes it much easier that is fine.

1.) The database will have the following

   `id` int(6) NOT NULL AUTO_INCREMENT,
   `username` varchar(100) NOT NULL,
 //   Taken from their login session().
   'minute' varchar(10) NOT NULL DEFAULT'',
//    Use_Selection
   'hour' varchar(10) NOT NULL DEFAULT'',
//    Use_Selection
   `Date` varchar(50) NOT NULL DEFAULT '',
//    Use Selection
   `Month` varchar(50) NOT NULL DEFAULT '',
//    Use Selection
   'Day_of_Week' varchar(10) NOT NULL DEFAULT'',
//    Use Selection
   `email_phone` varchar(50) NOT NULL DEFAULT '',
//    Edit box for email address or just username
   `provider` varchar(50) NOT NULL DEFAULT '',
//    Use Selection
   `message` varchar(120) NOT NULL DEFAULT '',
//    Edit Box
   `cron_command` varchar(120) NOT NULL DEFAULT '',
//    Hidden from user.
   PRIMARY KEY (`id`)


These below are only a reference. If you can change the code to work with one you only need to put a couple lines to show how it's done I should be able to make the rest work.

Minute ----------------------------
<option selected value="*">No Minute Selected</option>
<option value="15">15: Minutes</option>
Etc....

Hour -------------------------------
<option selected value="*">No Hours Selected</option>
<option value="24">12:00 - MID-NIGHT</option>
<option value="01">1:00am</option>
Etc...

Date ------------------------------
<option selected value="*">No Day of Month</option>
<option value="1">1</option>
<option value="2">2</option>
Etc..

Month -----------------------------
<option selected value="*">No Month of Year</option>
<option value="Jan">January</option>
<option value="Feb">February</option>
Etc...

Day if Week ---------

<option selected value="*">No Day of Week</option>
<option value="Sun">Sunday</option>
<option value="Mon">Monday</option>
Etc...

Provider ------------------------------------------

<option selected>No Provider Sent by eMail</option>
<option value="@text.wireless.alltel.com">Alltel</option>
<option value="@txt.att.net">AT&T</option>
<option value="@myboostmobile.com">Boost Mobile</option>
<option value="@sms.mycricket.com">Cricket</option>
<option value="@messaging.sprintpcs.com">Sprint</option>
<option value="@tmomail.net">T-Mobile</option>
<option value="@vtext.com">Verizon</option>
<option value="@vmobl.com">Virgin Mobile</option>
</select> 

[php]

<?php date_default_timezone_set('UTC'); // Says which errors to report // ini_set('error_reporting', E_ALL); // show errors/warnings/notices // ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING); // errors only (no notices or warnings) // top-level scripts like login will not define SUBDIR if(!defined('SUBDIR')) { define('SUBDIR', ''); } AdjustGPC(); // call stripslashes (if need to) on all $_GET/$_POST/$_COOKIE values // this is the date that gets autofilled into add.php // $date_default_timezone_set() $curr_date = date("m/d/Y"); // 05/24/2008 $curr_time = date("h:i A"); // 05:16 PM // Create $fields array and others // don't need to handle username // SUBDIR is also the name of the db table, so avoid funky chars! // assumes 'id' and 'username' are first 2 fields $fields = array(); $fields[] = array('name' => 'id', 'type' => 'varchar', 'len' => 20); // len will not be used, and i know id is not a varchar, // but it can be treated like one $date_selection_fields = array(); $totals_fields = array(); if(SUBDIR == 'Time') { $fields[] = array('name' => 'hour', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'minute', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'hour', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'date', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'month', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'day_of_week', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'email_phone', 'type' => 'varchar', 'len' => 120); $fields[] = array('name' => 'provider', 'type' => 'varchar', 'len' => 10); $fields[] = array('name' => 'message', 'type' => 'varchar', 'len' => 120); // When this var is set, will enable date selection for the given fields // $date_selection_fields = array('work_date'); } else if(SUBDIR == '') { // top-level scripts. Do nothing } else { // unknown SUBDIR die("SUBDIR[" .SUBDIR . "] not supported\n"); } // Create $field_names $field_names = array(); foreach($fields as $index => $field_info) { $field_names[] = $field_info['name']; } // Create the keyword_fields array. These are the fields that the keyword search will look at $keyword_fields = array(); foreach($fields as $i => $field_info) { $field = $field_info['name']; $type = $field_info['type']; // don't use it if it's the id field, or it's type is not varchar/text (so no date/file_upload) $types = array('varchar', 'text'); if($field != 'id' && in_array($type, $types)) { $keyword_fields[] = $field; } } // AdjustGPC(); // This function will call stripslashes on all the values in $_GET/$_POST/$_COOKIE if magic_quotes_gpc is ON. Else // it does nothing. // Call this function before you do anything with GET/POST/COOKIE values. // This traverses arrays, but it only changes bottommost values; it will never alter a key to an array function AdjustGPC() { // do nothing if magic_quotes_gpc is OFF if(!ini_get('magic_quotes_gpc')) { return; } StripArray($_GET); StripArray($_POST); StripArray($_COOKIE); } [/php]

If you need to charge something to help, let me know. I can do a little.

Sponsor our Newsletter | Privacy Policy | Terms of Service