Jump to content

coolbeansdude51

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by coolbeansdude51

  1. I have an array of UTC times. Lets say its: 10:52:48 13:52:27 09:12:37 10:32:34 09:12:21 13:20:12 I need to find the average of the hours. I am trying to do a couple of things. 1. Find the average 2. Find out how many times that specific hour is in the array 3. Convert that UTC hour, second, microsecond to the users specific timezone. I am thinking something like this. I haven't fixed it for an array as of yet. $broken_time=explode(':','10:52:48'); $time=date('H:i:s',mktime(-6+$broken_time[0],0+$broken_time[1],0+$broken_time[2],0,0,0)); echo $time; Any ideas?
  2. I am working with time in PHP and MySQL. I need to store a timestamp into a mysql database when something occurs on my server. I then need to pull that from the database and display it to the user in the users specific timezone. I plan on storing the users timezone in the database as well. I need to be able to convert that time to different time zones easily and simply. Should I use: php time()/date() mysql datetime/timestamp What is the easiest way to convert this time variable? Thanks so much for your knowledge!
  3. After a ton of trial and error I figured it out. The or die(mysql_error()) was the problem. Cut that out and it works like a champ. Here's the code that works. if($error == 'yes') { $_SESSION['mes']['type'] = 'error'; unset($error); header('Location: send_message.php'); exit; } else { require('../lib/functions.php'); require_once('../db.php'); $content = sanitize($_POST['content']); $groups = $_POST['group']; foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $test[$i++] = $row['phone']; }; }; }; var_dump($test); Any ideas why that would make it crap out?
  4. Its something to do with the while statement. If I comment it out it works fine. Humm. Idea's?
  5. Thanks for the reply michaellunsford! That didn't work ... Here is the entire piece of code I am working with. I hope this helps. if($error == 'yes') { $_SESSION['mes']['type'] = 'error'; unset($error); header('Location: send_message.php'); exit; } else { require('../lib/functions.php'); require_once('../db.php'); unset($error); $content = sanitize($_POST['content']); $groups = $_POST['group']; foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; $test[$i++] = $row['phone']; }; echo 'test'; var_dump($test); }; }; It does echo out the $row['phone'] fine. Right now ... It doesn't even echo out the test or do a var_dump of $test. What am I missing? It seems like I am just not seeing something. Probably because I have yet to sleep ... go figure. Any suggestions anyone? Thanks for the help so far!
  6. OK. I tried it trying to not just echo out the data but add it to an array and that didn't work. Any suggestions? Here's the code: foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; $test[] = $row['phone']; }; }; print_r($test); It echo's out the phone numbers but never adds them to the array ... any thoughts?
  7. That worked. Thanks for the help! The final code looks like this. Any suggestions? foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; }; } }; [/]
  8. Hello all, Here's whats up. I have a form which has a list of groups. The list of groups correspond with a groupid field in the usersgroups table. Each user can have multiple groups. For each group that the user is in there is a record in the table. The $groups variable is the $_POST['group'] from the form. In the form they can select multiple groups. I have [] in the form so no worries there. I need to select different users in the groups and then add them to an array ($mailer[]) to process through a mailer function that we have. I don't get any mysql errors or anything. Everything checks out with that. Yet I don't get the expected results or desired results. Can you all check my logic and help me out. When I echo out $row["userid"] 14 comes out ... I don't have a user with 14 as the id or even in my database at all. I don't know how that happened. Thanks in advance for your wisdom! foreach($groups as $g){ $query = "SELECT * FROM usersgroups WHERE groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result) or die(mysql_error())) { echo $row["userid"]; $query1 = "SELECT * FROM people WHERE id = '".$row["userid"]."'"; $result1 = mysql_query($query1) or die(mysql_error()); $row1 = mysql_fetch_array($result1) or die(mysql_error()); $mailer[] = $row1['phone'].$row1['provider']; }; }
  9. You are right ... I don't know much about normalization at all. Thanks for the idea! To make sure I understand you correctly. It would look something like this: record1 = member1 group1 record2 = member1 group2 record3 = member2 group1 Something to that effect ... Correct? Thanks for your reply and time. I really appreciate it.
  10. Hello all. Here is the problem. I have an application with users. I need to put those people into groups. Right now I have a separate table full of the groups. I query the groups table to place all the data in the form. Then I need to place data in table called members which has all the members data in it. Right now I have 1 field holding all the group data. I serialize the group array and then unserialize it when I need to pull it out. It works but I there has to be an easier way or a more correct way. I am running into problems when I need to build an msyql query to find members based on which groups they are in and then execute a script based on the members group association. Here are some thoughts: Would it just make more sense to create a field in the members table for each group? That would be a pain because the number of groups is constantly changing ... Pull in all the members into an array ... and the members groups then search through it building another array full of the members that meet the criteria ... Hopefully that makes sense. Let me know! Any idea's?
  11. @gizmola Thanks for your input. I misspoke when I said XML. I can get either XML or json. The majority of the data I gather is json data. (Its faster then XML with twitter ... go figure) Basically what we do is gather data about the people who are "following" a certain account on twitter. The problem lies in gather the appropriate data at the right time. We run it every hour so that we can get enough data to make our finding statistically relevant. The problem comes into play when the person who doesn't update there status since we last pulled the data. If they don't update there status for 1 full day that is 12 times that we pull data and the data says that for 12 times this 1 person has tweeted at the same time which skews our results. So we have to eliminate the people who have not changed there status and keep only the ones that have changed there status. All statuses have unique ids. We pull the unique id's place them in a DB then compare them the next time. If they changed and there are no duplicates then perfect. If there are duplicates we will throw away that set section of data but analyze the rest. When I mean analyze we only totals. Here is an example of what the data looks like in the database: timestamp id monday tuesday wednesday thursday friday saturday sunday UTCtime bestday num_records 2009-04-14 17:00:22 22 0 22 0 2 1 2 0 18:07:06 Tuesday 27 The data is then also summed up and then averaged once more to display the totals for the week. This will be done via a cron job and emailed out to the user on a day they specify. Does that help more??
  12. @humpty -- ahhh Yes? HAHAHA! Sorry! I am real tired. Thanks for your help!
  13. @Humpty -- Thanks for your knowledge! I didn't read your reply as well as I should have. My bad. You have been a tremendous help! Thanks so much! @Jason thanks for your comments as well. I have thought of keeping the entire xml data ... just not in the database. I was thinking using s3 to store it all. I am trying to keep my database as small and lean as possible. How would you suggest putting all of the status ID's in the database? One field that stores an array of them? Something to that effect. That just seems like a waste ... having 1 field where everything is stored ... I just had an idea!!! OK so follow me here. All I need to know is if the status is duplicated. So all I need to really know is if the ID's are duplicate. So if they are not a duplicate then that status ID can be deleted. Get it? If the ID's are found the second time then they need to be stored for a third time. If they arn't found then that's perfect and the ID's can be thrown away. What do you think? Does that make sense?
  14. Humpty, Thanks for the response. The ID's for the users are unique yes. No matter what the script can/will pull the users ID's I need it to. The users statues changes and each status has a unique id. I need to make sure when I call this script every hour that I don't get over lap from the last pull. I store the created_at data and the status itself. If that specific user doesn't change there status I will keep pulling that same data. That is what I want to avoid. Does that make sense? Anyone have any ideas!?
  15. Hello folks, I have a problem/question that I am hoping someone could help me problem solve. I have a script which runs every hour to pull data from Twitter. Specifically statuses from Twitter. The pulled data looks like this: <users type="array"> <user> <id>182791273</id> <name>username</name> <screen_name>username</screen_name> <location>USA</location> <description>sorry!</description> <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/182783123/twitter_normal.jpg</profile_image_url> <url>http://google.com</url> <protected>false</protected> <followers_count>19</followers_count> <profile_background_color>C6E2EE</profile_background_color> <profile_text_color>663B12</profile_text_color> <profile_link_color>1F98C7</profile_link_color> <profile_sidebar_fill_color>DAECF4</profile_sidebar_fill_color> <profile_sidebar_border_color>C6E2EE</profile_sidebar_border_color> <friends_count>32</friends_count> <created_at>Mon Sep 29 18:43:44 +0000 2008</created_at> <favourites_count>1</favourites_count> <utc_offset>-21600</utc_offset> <time_zone>Central Time (US & Canada)</time_zone> <profile_background_image_url>http://static.twitter.com/images/themes/theme2/bg.gif</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <statuses_count>26</statuses_count> <notifications>false</notifications> <following>false</following> <status> <created_at>Tue Apr 14 17:32:33 +0000 2009</created_at> <id>7128312612312</id> <text>In a meeting</text> <source><a href="http://help.twitter.com/index.php?pg=kb.page&id=75">txt</a></source> <truncated>false</truncated> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name></in_reply_to_screen_name> </status> </user> (Note: I have changed that data so it is anonymous) In the status section I want to just pull the data which has changed. The great part is that the ID in the status section is unique. So I can pull that and then re compare each status before the script runs so that I only get data which changes. Meaning each time I run the script the script first checks a database full of these unique IDs which are then compared to the IDs which are pulled for that hour. Once that is done it will only pull the IDs which are not a duplicate. Here's the problem. How can I save all of those ID's? Can I just stick them in a database and then pull the data again and then re compare? Can I stick all of the IDs in an array then place the array in a database? FYI some of the accounts will have upward of 5000+ users so that means 5000+ ID's every hour ... that could get big real quick. Processing that amount of data ... whats the lag time gonna be? Should I delete the data every ... week or so? What do you all think?
  16. They are backups. I know its a bad practice but unfortunately this is the only way right now. Suggestions?
  17. Hello forum! Hope everyone is doing well. I have a question for your genius! All I want to do is make sure that: 1. That in the user_data folder there is a folder named userid. 2. If that's not there then it needs to be created. 3. It then needs to check for another folder inside of that folder. The month and year. 4. If that's not there then it needs to be created. 5. Once all of those are check then it needs to create a file inside of that folder. Here is my logic. I know that the code below doesn't work but .... anyone have any suggestions? $timestamp = time(); $month = date('m_Y', $timestamp); $userid = '71625181'; if(file_exists('user_data/'.$userid.'/'.$month)) { echo 'level 1'; $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); } else { echo 'level 2'; mkdir('user_data/'.$userid.'/'.$month); $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); } else { echo 'level 3'; mkdir('user_data/'.$userid); mkdir('user_data/'.$userid.'/'.$month); $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); } or I was thinking this if(file_exists('user_data/')){ echo 'level 1'; mkdir('user_data/'.$userid); mkdir('user_data/'.$userid.'/'.$month); $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); } elseif(file_exists('user_data/'.$userid)) { echo 'level 2'; mkdir('user_data/'.$userid.'/'.$month); $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); } else { echo 'level 3'; $file = 'user_data/'.$userid.'/'.$month.'/'.$timestamp.".xml"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $xml); fclose($fh); }; Thanks for your input! -Adam
  18. I emailed the webmaster complaining ... he fixed everything. Go figure. Thanks for your help!
  19. BAH! Yes great question. The idea is that I would be able to use the data to post to a twitter account. Unfortunately the automated services can't read the feeds ... cause of all the errors. SO I decided that just creating my own would be easy. Done some work with the twitter API and it shoudlnt' be that hard. The problem is I can't get any of those tools that I normally use to work with those feeds that I posted. Normally I could use simpleXML to prepare the rss feed to easily enter it into twitter. Does that make sense? Thanks for the help/question! -coolbeansdude51
  20. I am attempting to phase an ill formed rss feed. Actually a couple of them. They don't validate via the w3 validator and I don't have the power/control to make them validate. I am stuck with them. So far I have already tried: simpleXML xmlReader magpierss None of them can phase the rss feed. Anyone have any suggestions? The feeds are: http://blink-cms.bethel.edu/channels/news-events/bethel-news-viewer/rss.xml http://www.bethel.edu/news/bu-news/rss.xml http://www.bethel.edu/e-news/rss.xml Thanks in advance for you wisdom and knowledge. I have been hitting my head against a wall for about a week now ... -coolbeansdude51
  21. Right ... but its a variable ... Its a post variable technically. $tz = -6 Thanks so much for the help so far! Just his one last thing has been bugging me!
  22. CRAP!! Ok. Something which I didn't take into account was the timezones which are 6.5 or something like that. Does this function take that into account? It doesn't look like it does. Any suggestions?
  23. That does worked! Thanks so much for your help!
×
×
  • 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.