Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. How would you like it displayed?
  2. On a side note the max value for hour if you are using a less than or equal to operator is 23 not 24. In a 24 hour clock 23:00 + 1 hour is 00:00. Just being picky.
  3. Not really. What if you wanted to pull a report on all people who worked longer than 5 hours?
  4. Firstly you should use MySQL TIME type for your 'diff' field. It would be even better if you could use the DATETIME format for the other 3 fields and include the date in the data. If you are using a VARCHAR then change it. To insert the missing data using the INSERT query you must first use PHP to calculate the time difference. To do this you will need the date. There is an issue. If the start time is say 5pm and the end time is 2am the following morning you will need the actual end date as just adding the current day to your time values will not work. So, $_POST['edin'] must be a datetime and $_POST['out'] must be a datetime YYYY-MM-DD HH::MM::SS It is then easy to find the time difference using a simple function. If you are using PHP 5.3 then there are objects that can do this much easier. <?php // function get the time difference between start and end date function get_time_diff($start, $end) { $diff = strtotime($end) - strtotime($start); $hr = floor($diff / 3600); $remaining = $diff - $hr * 3600; return sprintf('%02d', $hr) . gmdate(':i:s', $remaining); } // this should be what is in your $_POST['edin'] variable $start = '2013-07-01 12:20:00'; // this should be what is in your $_POST['out'] variable $end = '2013-07-01 12:23:00'; // should print 00:03:00 $out = get_time_diff($start, $end); echo $out; ?>
  5. $serial->sendMessage("The big Brown Fox jumped over the cold lazy dog\n") ; $serial->sendMessage("Message 2\n"); // Or to read from $read = $serial->readPort(); echo nl2br($read); echo "line 1" . "<br>"; echo "line 2" . "<br>"; echo "line 3" . "<br>";
  6. Show us some of your data as it is displayed in the table and then show us the values you expect to be in your empty fields.
  7. You can't use a URL in the move_uploaded_file() function for the destination parameter. Use a proper path and make sure the directory has write permissions. // bad move_uploaded_file($_FILES["file"]["tmp_name"], "http://www.jasondoyleracing.com/news-images/" . $newfilename); // good move_uploaded_file($_FILES["file"]["tmp_name"], "/public_html/news-images/" . $newfilename);
  8. $data holds the query row in your loop not $list $list = mysql_query("SELECT name, email FROM ".mysql_real_escape_string($_POST['db1'])); $mailList = array(); while($data = mysql_fetch_assoc($list)) { // probably better to use email as the array key as it is unique $mailList[$data['email']] = $data['name']; } echo '<br /> var dump <br />'; var_dump($mailList); echo '<br /> var dump <br />';
  9. Remember, PHP is only executed on the server, not by a web browser. So, for PHP to do anything with form data it must first get to the server, i.e the form must be submitted. As Psych has stated, if you want the data to be processed as soon as something is entered into the text field (you have termed it reactive), then you require code that the browser understands to get the input data to the server without the user clicking a submit button. PHP can then deal with the data and send a response back. Javascript is needed (AJAX). To make your life simple I would use the JQuery framework. Have a look at this simple tutorial which pretty much does what you are after. http://www.phptutorialforbeginners.com/2013/01/jquery-ajax-tutorial-and-example-of.html
  10. You can setup any dummy website or websites for testing your SEO using wordpress or even a single 1 page site and try to rank it for certain keyphrases. You can play with meta data in wordpress if you like using plugins or adding to the code yourself.
  11. SEO is a trial & error game. Sure, there is plenty of material out there regarding on-site optimization such as page titles, descriptive anchor links, friendly urls, meta data, etc. However, off-site is key i.e link building, etc, but remember too much, too soon and Google may find you out and de-index your site quickly. Google's algorithms change often, that is why there is no black and white, 'do this and your site will rank' method. People who are good at SEO will never reveal their methodology, i.e the tools they use.
  12. Even simpler <?php function url_strip($url) { $parts = parse_url($url); return str_replace('www.', '', $parts['host']); } echo url_strip('http://www.thiswebsite.co.uk'); ?>
  13. Advantages: No need to learn PHP, etc if you are using it straight out of the box, quick to setup Disadvantages: Possible security holes, need to install patches for bug fixes, may not have a feature that you or a client requires in their website, looks and feels the same as other websites using the same system, possible steep learning curve if you wish to modify the code yourself to add new functionality. This applies to any CMS, not just the one you mention
  14. You are missing the query function. $result = mysql_query("SELECT * FROM applications WHERE id ='" . mysql_real_escape_string($app) . "'");
  15. Are you using an off-the-shelf application for this website such as osCommerce?
  16. Let me elaborate. You should not store delimited ids in a text field as you will end up with a mass of issues down the line. To normalize your database you need to do the following (I am guessing your table / field names) players ======= player_id (int) name (vc 50) announcements ============= an_id (int) content (vc 255) players_to_announcements ====================== id (int) player_id (int) an_id (int) date_read (datetime) So if you have 3 players in the players db table with ids 1, 2, and 3 and you have an announcement in the announcements table with an id of lets say 456, if a player reads an announcement you record this by storing a record in the players_to_announcements table. If player id 2 & 3 have read the announcement the data will look as follows: 1 | 2 | 456 | 2013-01-01 01:00:00 2 | 3 | 456 | 2013-01-01 02:00:00 You can then easily query this data to find what players have read each announcement
  17. You may need to change the way your checkout functions. If your website is setup where you need to complete a registration form, then login before they can add to basket and proceed to checkout I would scrap that. Firstly, i'm guessing that your database design will not allow orders to be disjointed from a customer, i.e they need a customer ID. I would change your website so customers are actually registered on checkout whether they are going to come back to your website or not. When they checkout the first thing you can do is ask for their email address and password. If they dont have an account i.e If they are a first time buyer they still need to enter their details for shipping, payment, etc on your website so you can capture this and register them at this point and complete the checkout. Similar to how Amazon works. I would not be looking at deleting any information. What if a customer needs to print off an invoice in the future? If you have deleted their record there is no way that they can do this. Customers should always be registered, it is the order process that should be ammended.
  18. $tel = '0123456789'; if (preg_match('/(0[0-9]{9})/', $tel)) { print "valid"; } else { print "invalid"; }
  19. Take a look at this lib http://www.fpdf.org/
  20. Then all is forgiven LOL
  21. If you are going to store the start time in a database then you still require an identifier for the user upon returning to the page. This is not a problem if you must login prior. This is why I suggested using a cookie.
  22. The way I would tackle this is by using a cookie. When the user hits the start button I would set a cookie that contains the time that the button was clicked. You can then read this value and add 5 minutes to it to get your expiry time. If the current time is greater than the expiry time you will know that the user has ran out of time. To display a counter you will need to use javascript and a little bit of ajax to get the required data from the server. By using a cookie, a user can leave your website, close their web browser, etc, come back and the data will still be available. PHP has lots of time functions. For instance to get the current time as a unix timestamp, simply use time(). All of PHP's date & time functions are listed on the left of the manual page http://php.net/time What you are trying to do will require a decent knowledge of PHP / JS / AJAX
  23. Undefined index means that you are attempting to access data inside an array (in this case the $_POST array) using a key that doesn't exist. Your error is due to either the form field name being spelled different to HouseNumberName and CityTown, or there is no data present in the field. What you are getting is a notice (more of a warning than an error) and your code should still function. However to clean this up check your form field names are correct and the same as what you are using as the $_POST array key and always check that data exists and is set before attempting to use it in any way i.e // check if data is present and store in variable. if not variable will be FALSE $house = (isset($_POST['HouseNumberName']) && !empty($_POST['HouseNumberName'])) ? $_POST['HouseNumberName'] : FALSE;
  24. This is certainly not something you want to be doing using your web browser. This is the sort of thing suited to a command line script. I'm not sure why you would not know the exact xml urls that need reading, please elaborate. You have a simple error in your code. Variables are not translated inside single quotes, only inside double quotes. If you want to use single quotes then the following will work: $possibleids = range(1,100); foreach ($possibleids as $value) { $xml = 'http://www.website.com/item=' . $value . '&xml'; }
  25. I will have to look at keeping a copy of the original upload at a specific resolution as you guys have suggested for future projects. As I am not a designer I have never been given a design that required an original size image. I have always scaled and optimized images to the size required on the design and destroyed the original.
×
×
  • 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.