Jump to content

sniperscope

Members
  • Posts

    280
  • Joined

  • Last visited

Everything posted by sniperscope

  1. if(isset($_POST['id'])) { mysql_query("TRUNCATE TABLE work"); $sql = "INSERT INTO work(staff_id, Mon, Tue, Wed, Thu, Fri, Sat, Sun) VALUES "; $counter = count($_POST['id']); for($i=0; $i<$counter; $i++) { $Mon = ($_POST['From1'][$i] == $_POST['To1'][$i]) ? '~' : $_POST['From1'][$i] .'~'. $_POST['To1'][$i]; $Tue = ($_POST['From2'][$i] == $_POST['To2'][$i]) ? '~' : $_POST['From2'][$i] .'~'. $_POST['To2'][$i]; $Wed = ($_POST['From3'][$i] == $_POST['To3'][$i]) ? '~' : $_POST['From3'][$i] .'~'. $_POST['To3'][$i]; $Thu = ($_POST['From4'][$i] == $_POST['To4'][$i]) ? '~' : $_POST['From4'][$i] .'~'. $_POST['To4'][$i]; $Fri = ($_POST['From5'][$i] == $_POST['To5'][$i]) ? '~' : $_POST['From5'][$i] .'~'. $_POST['To5'][$i]; $Sat = ($_POST['From6'][$i] == $_POST['To6'][$i]) ? '~' : $_POST['From6'][$i] .'~'. $_POST['To6'][$i]; $Sun = ($_POST['From7'][$i] == $_POST['To7'][$i]) ? '~' : $_POST['From7'][$i] .'~'. $_POST['To7'][$i]; $sql .= "('" .$_POST['id'][$i]. "', '" .$Mon. "','" .$Tue. "','" .$Wed. "','" .$Thu. "','" .$Fri. "','" .$Sat. "','" .$Sun. "'),"; } $sql = substr($sql, 0, (strlen($sql) - 1)); $sql .= ";"; mysql_query($sql); header('location: index.php'); }
  2. by the way i forgot to mention that my new server has php 5.4.10 and old one was 5.3.20
  3. Hello all Recently i have posting problem. I transfer my web page to new hosting server and since then i am facing problem with post data. I have a schedule form with 83 user which is posting one week schedule which means my form is posting 581 + (3 hidden form data) when i click Submit form. So far i have changed max_execution_time => 300 max_input_time => 600 memory_limit => 100M post_max_size => 80M upload_max_filesize => 80M in my previous server's values was 1/4 of above value and didn't have any problem even once. Output of my hidden value return NULL for testing purpose var_dump($_POST['test']); returns NULL even before and after form submission. Thank you for any help and/or idea Regards
  4. Different approach. Unfortunately, i cannot change db construction. What i want is list today's worker after 10pm and include everybody who works tomorrow. So, in my query bring today's and tomorrow's workers who works after 10pm.
  5. Hello i have a list in my database and i want to list them order by date and hour. Unfortunately my following sql query brings me wrong value. I need that display staff_id who works today and after 5pm and all from tomorrow. Example output should be like: |_Id_|___date___|__hour__| | 2 | 2013/4/18 | 22:00 | | 5 | 2013/4/18 | 22:30 | | 8 | 2013/4/18 | 23:30 | | 9 | 2013/4/19 | 00:30 | | 21 | 2013/4/19 | 00:30 | | 22 | 2013/4/19 | 01:00 | | 7 | 2013/4/19 | 01:30 | | 16 | 2013/4/19 | 02:00 | SELECT s.shop_name, g.staff_name, g.staff_id, w.staff_start, w.staff_end FROM work_master w LEFT JOIN staff_master g ON w.staff_master_id = g.staff_id LEFT JOIN shop_master s ON w.shop_id = s.id WHERE w.work_date BETWEEN '2013/4/18' AND '2013/4/19' AND w.staff_start >= '22:00' GROUP BY w.staff_master_id ORDER BY w.work_date ASC, w.staff_start ASC Above query gave me this output : |_Id_|___date___|__hour__| | 2 | 2013/4/18 | 22:00 | | 5 | 2013/4/18 | 22:30 | | 8 | 2013/4/18 | 23:30 | | 19 | 2013/4/19 | 22:00 | | 29 | 2013/4/19 | 22:30 | | 41 | 2013/4/19 | 23:00 | | 7 | 2013/4/19 | 01:30 | | 16 | 2013/4/19 | 02:00 | Appreciate for any help
  6. Hello Thanks for advice. Personally, i never store image files into database. The someone did it who built homepage at first and now i have to clean up his mess because he used php script to display images therefor, server has load problem
  7. Hello I am facing a problem like importing huge (2.5gb) sql file into new server. Super moron who create web page, saved image files into db. So first i have to import that sql file then convert image strings into image file. The first thing i thought open sql file and insert one by one but this time i have two problem; one: db is huge so text editors cannot open it and second there is about 80.000 records in it. How can i handle this task? Regards
  8. Dear Jcbones I am so thank you for that function. I even doidn:t know that php has so useful function. Okay, i guess i found what makes that problem. Seems, first loop cause it, at for($i = $start_hour; $i <= $mid_nght; $i += 1800) $arr[] = $i; So i remove it(commented) and than script throw me error on second loop. And i removed it as well, whoola page load fine. I do not want to touch to server's max_memory because this is at test now and if only visitor(me) make that much problem, i cannot imagine 1000 visitors at same time. So, i think, i have to re-think and optimize and re-create my codes from all over again.
  9. Yes that function belong to query class and i guess problem is array That function display some data at left side of side and it is include every single page.
  10. hello I am getting Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 32 bytes) in /home/accnt/public_html/connection/class_query.php on line 499 Code is below: i have no idea why is this happening... function WorkPanel() { $count = 0; $today = date("D", $this->Day1()); $day_change= $this->StoreInfo("day_change"); $arr = array(); $hr = date("H"); $min = (date("i") < 30) ? "00" : "30"; $now = strtotime($hr .":". $min); $sql = mysql_query("SELECT " .$today. " FROM work WHERE " .$today. " != '' AND area = '" .$this->area. "'"); while($row = mysql_fetch_array($sql)) { $working_hour = explode("~", $row[$today]); $start_hour = strtotime($working_hour[0]); $end_hour = strtotime($working_hour[1]); if($working_hour[1] >= "00:00" && $working_hour[1] <= "07:00") { $mid_nght = strtotime("23:59"); for($i = $start_hour; $i <= $mid_nght; $i += 1800) $arr[] = $i; array_push($arr, $i); $over_mid_start = strtotime("00:30"); $over_mid_end = strtotime($bitis); for($i = $over_mid_start; $i <= $over_mid_end; $i += 1800) $arr[] = $i; } else { if($working_hour[1] == "00:00") $mid_nght = "23:59"; for($i = $start_hour; $i <= $mid_nght; $i += 1800) $arr[] = $i; if($working_hour[1] == "00:00") array_push($arr, $i); } if(in_array($now, $arr)) $count++; unset($arr); } return $count; } Regards
  11. Hello I have some serious date and time problem and i am working on it for 3 days without any hope. On my current job day change at 07:00 and i cannot calculate to see if person working or not if his job end after 00:00 My current code work fine if current time until 07:00am but fail after it. // Find end hour $working_hour = explode("~", "10:00~01:30"); // Explode it to hour and minute $ending = explode(":", $working_hour[1]); $mid = ($working_hour[1] > "07:00" && $working_hour[1] < "23:59") ? 1 : 0; $end_hour = mktime($ending[0], $ending[1], 0, date("n"), date("d") - $mid, date("Y")); $current = mktime(date("H"), date("i"), 0, date("n"), date("d"), date("Y")); // Return result if($end_hour < $current) return "-"; else if($row['left_min'] > 0) return "You have " .$row['left_min'] ." minutes left"; else return "you are done"; However; yesterday i wrote some code which works perfect for single count but fail in loop. Here it is; $array_for_hour = array(); $working_hour = explode("~", "10:00~01:30"); // if job end after midnight if($working_hour[1] > "23:59" || $working_hour[1] > "00:00") { $start_hour = strtotime($working_hour[0]); $end_hour = strtotime("23:59"); // Add into array every 30 minutes for($i = $start_hour; $i <= $end_hour; $i += 1800) { $array_for_hour = $i; } // Add another 30 minutes to comlete to 00:00 array_push($array_for_hour, $i); $midnight_start = strtotime("00:30"); $midnight_end = strtotime($working_hour[1]); // Add hours into array from midnight to actual end hour for($i = $midnight_start; $i <= $midnight_end; $i += 1800) { $array_for_hour = $i; } } else { $start_hour = strtotime($working_hour[0]); $end_hour = strtotime($this->bitis_saat); if($end_hour == "00:00") $end_hour = "23:59"; for($i = $start_hour; $i <= $end_hour; $i += 1800) { $this->arr[] = $i; } if($end_hour == "00:00") array_push($array_for_hour, $i); } Thanks for any help and advise. Regards
  12. Dear Fenway. I am going to follow the path as i described in my previous post. Thank you so much for your attention and help. Have a nice day.
  13. yes sir. User password is all uppercase and i am 100% sure login credentials are correct
  14. My Password include lower/upper case and special character with 16 chars long and I Copy and paste from original connection string. Is that possible that something on server A or B is blocking communicate. Currently my servers has CSF firewall, iptables and ddos deflate. This is last thing i am thinking.
  15. nope, i always use utf8-general-ci. I am trying to do is: 1 - Check user is really exist and valid when he click "Log in" button. 2 - After succesfully logged in then display his/her entire detail. 3 - If he/she edit/delete something then update on remote server db. /* Off Topic */ It says "Advanced Member" in my profile but somehow i am still asking simple php question. What an irony /* Off Topic */
  16. @Barand: There is no error on output. But select query is return with 0 result. @Fenway : What am i doing is Just use same database at two different server. User can login from Server B by sql query at Server A. While waiting some help, i had a crazy idea. Not sure if it works or not but want to give a try. Create same db at Server B as well, So if user update at Server A then updated parameters send to Server B through cURL. Delete and insert wil work same way. So i will have two different DB but simultaneously synchronize. Is this good idea?
  17. Hello I have two physically seperated server and i want to Read, Update and Insert into remote server's database. My connection code is working <?php $cn = mysql_connect("xxx.xxx.xxx.xxx:3306", "username", "password"); mysql_select_db("db_name", $cn); ?> however, when i try to retrieve data from remote server i got nothing to return. $sql = mysql_query("SELECT id FROM user_master WHERE user_id = '" .$name. "' AND user_pass = '" .$pass. "' LIMIT 1"); $row = mysql_fetch_array($sql); if(mysql_num_rows($sql) == 0) echo "wrong username or password"; else header("location: index.php"); What am i doing wrong ?
  18. Hello I am trying to figure out something of my project for 4 days but seems i have no luck. And lastly i decided post a topic here and hopefuly to get help. What am i trying to do is hourly schedule, please let me explain. Let's say we have a staff who call him Mr. A And mr. A works today from 19:00 to 23:00 also mr. A has schedule such as following 19:00 to 19:20 free 19:20 to 20:40 working at Station A 20:40 to 20:50 free 20:50 to 22:10 working at Station B 22:10 to 23:00 working at Station C My sample data is: CREATE TABLE IF NOT EXISTS `reserv` ( `r_id` int(6) unsigned NOT NULL AUTO_INCREMENT, `staff_id` int(4) NULL, `r_date` int(10) NULL, `start_to_work` varchar(5) NULL, `start_to_work_len` int(2) NULL, PRIMARY KEY (`r_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; INSERT INTO `reserv` (`r_id`, `staff_id`, `r_date`, `start_to_work`, `start_to_work_len`) VALUES (1, 1, 1354460400, '19:20', ; in here table says: Staff who has id #1 going to work 19:20 to 8 times 10 minutes(which means 80 minutes) at 2012/12/3 On my html is: <tr> <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td> <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td> <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td> <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td> <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td> </tr> <!-- Every single hour has 6 <td></td> which reference to 10 minutes --> <tr><th colspan="6">19:00</th><th colspan="6">20:00</th><th colspan="6">21:00</th><th colspan="6">22:00</th></tr> <tr> <td colspan="2" style="background-color:blue;">Free<br />19:00<br />~19:20</td> (colspan is 2 because he has 20 minutes free time) <td colspan="8" style="background-color:red;">working<br />19:20<br />~20:40</td>(colspan is 8 because he has 80 minutes working time) <td colspan="1" style="background-color:blue;">Free<br />20:40<br />~20:50</td> (colspan is 1 because he has 10 minutes free time) <td colspan="8" style="background-color:red;">working<br />20:50<br />~22:10</td>(colspan is 8 because he has 80 minutes working time) <td colspan="5" style="background-color:red;">working<br />22:10<br />~23:00</td>(colspan is 5 because he has 50 minutes working time) </tr> So far, i can make table with a blank <td> by; function BlankTd() { $blank_td = '<tr>'; for($i=$this->work_from; $i<$this->work_to; $i++) $blank_td .= ' <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>'; $blank_td .= '</tr>'; return $blank_td; } and working hours by; function Working() { $working_td = '<tr>'; for($i=$this->work_from; $i<$this->work_to; $i++) { $working_td .= ' <th colspan="6">' .$i. ':00</th>'; $this->works[] = $i; } $working_td .= '</tr>'; return $working_td; } And where did i stopped, i cannot make any further. I really appreciate for any help or advice.
  19. Hi. I am having some difficult times for 3 days. Searched over net but i couldn't find good tutorial or example. What i want is just drag a div element into Garbage Icon and delete from mysql. I got one example site http://jsfiddle.net/KWdcU/40/ exactly what i want unfortunately it deletes all element at once. And i have no idea how to populate mysql as well. I will be much appreciate for any help or guide me to a tutorial site. Regards
  20. Dear derrck You were right. I have checked file and php encoding. Stupid guy who sitting next desk create file in Shift_JIS format and i didn't checked. After your post, i have checked encoding and change into correct encoding. It is working now. I really want to thank everyone who tried help me out. Without you guys probably i would have 2-3 more days headache. Have a great days.
  21. Hello (a) I am using correct server (b) No i am not using wrong database because database connection is in inc/cn.php and all files in the site using that file for db connection © No, I've checked maybe 50 times word by word for both query. (d) No, I even copy entire query from working page to NON-working page. Same query fail @smoseley: Here is the result of echo: Resource id #3 I am facing this kind of weird problem first time in my life.
  22. How this can be? Could you please little specific. Regards
  23. Thanks for reply. I've just tested and no hope. Still same.
×
×
  • 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.