Jump to content

honkmaster

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by honkmaster

  1. Hi I'm trying to record the status of a user when they log out but I can't work out where I'm going wrong. Any help would be fantastic Cheers Chris Button <a href="<?php echo $logoutAction ?>">Log out</a> Log Out <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); //Record log in and out Status $query=("UPDATE authorise SET authorise.authorise_status = 'Logged Out' WHERE authorise.authorise_username = '$_SESSION[MM_Username]'"); $result=mysql_query($query); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; $_SESSION["skill"] = NULL; $_SESSION["email"] = NULL; $_SESSION["firstname"] = NULL; $_SESSION["department"] = NULL; $_SESSION["fullname"] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); unset($_SESSION['skill']); unset($_SESSION['email']); unset($_SESSION['firstname']); unset($_SESSION['department']); unset($_SESSION['fullname']); $logoutGoTo = "../index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?>
  2. Thank you so much, that was great and worked perfectly, is there any way of getting the Year in there as well? Cheers Chris
  3. Hi, I'm trying to Select all records in my database based on month and count them. The dates are store as unix timestamp as below. So if I wanted to return all records for November 2019 the result would be 5 based on below. I have started the query as below but I'm not sure if DATEPART() is there correct way to finish. SELECT COUNT(Target) FROM production WHERE DATE(FROM_UNIXTIME(production.Target)) = Target ---------- 1574701200 1574701200 1574701200 1574701200 1574701200 1572436800 1572436800 1572436800 Cheers Chris (PHP/SQL Novice)
  4. Hi Thank you very much for your response, which is a great solution. The issue we have is the data comes in as displayed. What we are trying to do is not have to manipulate the data as this is the bit that takes time. So the benefit is only there is sql or php can produce the result as displayed in the result jpg. Cheers Chris
  5. Hi, I have been stuck on best way to achieve the following (I'm still learning php and Sql so for give me if this is obvious) I have a table (See Screen Shot) which has the following headings placeID, place, job1, job2, job3, job4, job5 etc I'm trying to run query which will return as the the result screen shot attached. I'm not sure if I should be doing this within PHP or SQL? What I have is correct for job 001but i need all the other jobs underneath as in screen shot. SELECT Campaign.PlaceId, Campaign.Place, Campaign.`001` FROM Campaign WHERE Campaign.`001` >='1' Any help would be great, Cheers Chris
  6. Below is code with posted data, result is 1 hr 43 mins which is incorrect, start time is 13:12 and finish is 13:55 which is 43 mins <?php $start = '1491480732'; $finish = '1491483308'; $difference = ($finish - $start); $day = round(($difference % 604800) / 86400); $hours = round((($difference % 604800) % 86400) / 3600); $minutes = round(((($difference % 604800) % 86400) % 3600) / 60); echo $day." days"."<br/>"; echo $hours." hours"."<br/>"; echo $minutes." minutes"."<br/>"; ?>
  7. Hi, thanks for response, dateTime is stored as unix
  8. Hi, I have two date and time stamps stored in my database, I'm using the below script to calculate the difference but whenever I'm getting an extra 1 hour added ?? Any ideas, Cheers Chris <?php $start = $row_rsComplete['quote_added']; $finish = $row_rsComplete['quote_complete']; $difference = ($finish - $start); $day = round(($difference % 604800) / 86400); $hours = round((($difference % 604800) % 86400) / 3600); $minutes = round(((($difference % 604800) % 86400) % 3600) / 60); echo $day." days"."<br/>"; echo $hours." hours"."<br/>"; echo $minutes." minutes"."<br/>"; ?>
  9. Ok that worked perfectly, thanks for help, if I wanted to use a date in the passed or future do use DATE_ADD() and DATE_SUB() instead of CURDATE() ? Once again thanks for help Cheers Chris
  10. Thanks for response but still getting a 0 count when it should return a result, if I remove date part it works so issue is with how the query is comparing the stored unix date/time and the date today 2015-06-08??
  11. Hi look for some help with querying based on todays date. I'm trying to count all the entries in the database based on username, status, date. The date bit is where I' stuck (see screen shot of database) Based on data in database I should get a count of 3 but get nothing?? The result I get is 0 and should be 3 based on date Any help would be a great help Cheers Chris //date bit $d=strtotime("today"); $wholedate2 = date("Y-m-d", $d); //query $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND quotes.quote_complete = '$date2' AND quotes.quote_status = 'Complete'";
  12. I new that as well, can't see wood for trees sometimes, thanks
  13. Hi, I could do with a bit of help with this, not sure where I'm going wrong. The following code is used to change the colour of a row based on date. I want to compare to todays date with the following results If < today (turns red) if == today (turns orange) if > today (turns green) I have included a screen shot of result I'm getting with below if statement <?php $requireddate = date('l jS F',$row_rsActiveQuotes['quote_requireddate']); //this is anthing before today's date if ($today < $requireddate) { echo '<tr class="tableBody2">'; } //this is anthing with today's date elseif ($today == $requireddate) { echo '<tr class="tableBody3">'; } //this is anthing with today's date elseif ($today > $requireddate) { echo '<tr class="tableBody1">'; } else //this is anthing from tommorow { echo '<tr class="tableBody4">'; } ?>
  14. Hi, I'm stuck on below, I have a table called History that records date and time as timestamp, example attached below I'm trying to count the number of entries with todays date, below is the php for todays date and the query, Any one help point me in the write direction. $d=strtotime("today"); $wholedate = date("Y-m-d", $d); $date_array = explode('-', $wholedate); $date = mktime(0,0,0,(int)$date_array[1],(int)$date_array[2],(int)$date_array[0]); $query_rsWorkedToday = "SELECT COUNT(*) FROM history WHERE history_date = ‘$date’”;
  15. Thanks, do you know of examples using a drop down list?
  16. I have a form that has a drop down list that gets company details from mysql database when the company name is selected. When the form is completed it will not submit??? If I remove the script that gets the data from the database i can submit the form? I'm not the best at javascript, so could do with pointing in the right direction!! Cheers Chris <script> function showCompany(str) { if (str=="") { document.getElementById("customerDetails").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("customerDetails").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getcustomer.php?customer_id="+str,true); xmlhttp.send(); } </script>
  17. Thanks for help, I get a syntax error on all echo lines? Cheers Chris
  18. Hi, Any help would be great I have the following code which is looking at two dates, due date and today. <?php[/font][/color][color=#232323][font='Helvetica Neue'] date_default_timezone_set('Europe/London');[/font][/color][color=#232323][font='Helvetica Neue'] $now = time();[/font][/color][color=#232323][font='Helvetica Neue'] if ($row_rsReleaseQue['duedate'] < date('d-m-Y',$now)) { echo '<tr class="tableBody3">'; } else { echo '<tr class="tableBody1">'; } ?> I want to change the background colour of the line in my table based on the due date. < less that todays date = Red (tableBody3) == equal to today = Orange (tableBody2) > greater than today = Green (tableBody1) Cheers Chris
  19. Thank you very much for your help, I now understand where I was going wrong, Cheers Chris
  20. first part of script this cam up INCOMING ARRAYS: $_POST: Array ( [company] => test [nouploads] => 1 [submit] => Submit ) $_FILES: Array ( ) Then when I submit the file I this INCOMING ARRAYS: $_POST: Array ( [MAX_FILE_SIZE] => 2000000 ) $_FILES: Array ( [userfile] => Array ( [name] => Array ( [0] => test 2.JPG ) [type] => Array ( [0] => image/jpeg ) [tmp_name] => Array ( [0] => /Applications/XAMPP/xamppfiles/temp/phprNKfX2 ) [error] => Array ( [0] => 0 ) => Array ( [0] => 409173 ) ) )
  21. I added and got the following Notice: Undefined variable: undefined_variable in /Applications/XAMPP/xamppfiles/htdocs/workflow/upload3.php on line 13
  22. No error when I test at all, it seems to be the Variable $target is not working at the end of line starting $upload_dir. I have put the echo in to see what is working?
  23. Ok, I have put on error reporting and fixed errors, I have also added echo to see what is happing. All works apart from the file does not end up in the "company" directory it ends up in the "image" directory with the "company" folders. This is what is echoing back to start with "uploads/image/CompanyName/" Once the Directory is created it should put the uploaded files in the "CompanyName" directory. What i get echoed back is "uploads/image//" the "CompanyName" is missing Very confused, any help would be great Cheers Chris <?php error_reporting(-1); //posted from form if(isset($_POST['company'])) $target = "$_POST[company]"; if(isset($_POST['nouploads'])) $nouploads = "$_POST[nouploads]"; { global $target, $nouploads, $dir; } echo $target; echo "<br />"; //make a dir with the same name as company //does not matter if it already exists if (!file_exists ( "uploads/image/$target/" )) { mkdir("uploads/image/$target/", 0777, true); } //directory to upload to $upload_dir = "uploads/image/$target/"; echo $upload_dir; echo "<br />"; //number of files to upload passed by form $num_uploads = "$nouploads"; //maximum filesize allowed in bytes $max_file_size = 2000000; //the maximum filesize from php.ini $ini_max = str_replace('M', '', ini_get('upload_max_filesize')); $upload_max = $ini_max * 2000000; //a message for users $msg = 'Please select files for uploading'; //an array to hold messages $messages = array(); //check if a file has been submitted if(isset($_FILES['userfile']['tmp_name'])) { //loop through the array of files for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++) { //check if there is a file in the array if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i])) { $messages[] = 'No file uploaded'; } //check if the file is less then the max php.ini size elseif($_FILES['userfile']['size'][$i] > $upload_max) { $messages[] = "File size exceeds $upload_max php.ini limit"; } //check the file is less than the maximum file size elseif($_FILES['userfile']['size'][$i] > $max_file_size) { $messages[] = "File size exceeds $max_file_size limit"; } else { //copy the file to the specified dir if(@copy($_FILES['userfile']['tmp_name'][$i],$upload_dir.'/'.$_FILES['userfile']['name'][$i])) { //give praise and thanks to the php gods $messages[] = $_FILES['userfile']['name'][$i].' uploaded'; } else { //an error message $messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed'; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Multiple File Upload</title> </head> <body> <h3><?php echo $msg; ?></h3> <p> <?php if(sizeof($messages) != 0) { foreach($messages as $err) { echo $err.'<br />'; } } ?> </p> <form enctype="multipart/form-data" action="upload3.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" /> <?php $num = 0; while($num < $num_uploads) { echo '<div><input name="userfile[]" type="file" /></div>'; $num++; } ?> <input type="submit" value="Upload" /> </form> </body> </html>
  24. I have tried with double quotes as //directory to upload to $upload_dir= "uploads/image/$company"; I'm just trying to understand why it isn't working??
×
×
  • 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.