Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. I would use the HTTP status header to see if the file is valid. If a 200 response is returned then the file is definatly there. Use fsockopen() to do this. Example: <?php // obtain http header for a given url filepath function file_exists_from_http_header($server, $filepath) { $fp = fsockopen($server,80,$errno,$errstr,30); $out = "GET /".$filepath." HTTP/1.1\r\n"; $out .= "Host: $server\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp,$out); $content = fgets($fp); if(strstr($content, "200 OK")) { // file exists return true; } return false; } // usage if(file_exists_from_http_header("www.google.co.uk", "intl/en_uk/images/logo.gif")) { print "file exists"; } else { print "file does not exist"; } ?>
  2. use an onload event to restore the boxes from the ajax script. use a page parameter to trigger it. you may need to write another js function that handles this.
  3. Yes, dont use javascript, use CSS // css document div.game:hover { background-color: #FF0000; } <div class="game">Game 1</div> <div class="game">Game 2</div>
  4. This should be easy enough to make yourself if you are familiar with php/mysql. In terms of the scanner, use javascript with an onLoad event to set the focus of the field that requires the barcode.
  5. http://www.smartcode.com/downloads/import-excel-mysql-php-mysql-script.html
  6. Go to http://hotscripts.com There is a detailed description of each script
  7. You should set the mysql date field as a NULL field. If a date isn't entered into your form then your sql should insert NULL, not an empty value (SET dateField=NULL). You are correct all dates should be in the format of YYYY-MM-DD. When outputting the date you should check for a value first if($row['dateField']) { $row['dateField'] = date("d-m-Y", strtotime($row['dateField'])); } print $row['dateField'];
  8. Set the default value for the field to 0000-00-00 This is an invalid mysql date format: 00-00-0000 should be yyyy-mm-dd
  9. eh. Explain
  10. What the f*** is that? How would you want to output? Provide a template.
  11. If your server cannot ping a website's IP address i.e. 87.58.96.33 (example) then your server has no internet connection. If it can ping public IP addresses then your DNS settings are invalid.
  12. Yes, needs to return days, hours, minutes
  13. Sorry, forgot to mention that working days are mon-fri. Weekends do not count. My bad.
  14. Thanks Can you lay down a bit of code. Psuedo code if easier. Ta.
  15. Hi all. Bit braindead at the moment so need a bit of help. I need a function that will calculate the difference in days/hours/minutes from 2 given datetimes. This is simple enough in itself, not a problem however it must only count the time through a working day of 8 hours i.e. 9-5 so if the start datetime was 2009-07-27 11:00 and the end was 2009-07-28 11:00 then it would return 8 hours not 24. The start and end datetime can be a time prior to 9 and after 5 also so if prior then the counter starts from 9 the same as if after 5pm (start 9am the next day). They could also be on the same day. Any ideas on a formula?
  16. I dont know how I can explain it easier. If you ever insert into a database or update a record always reload the page using the header() function after the query. This will prevent multiple records being inserted if the user was to click the refresh button in their browser (it will keep running over the same bit of code). You only run the queries when a user clicks the form submit button right? So if you reload the page the form is not in submit mode. To check if a name already exists then you would write a SELECT query prior to an insert query. See if the name exists from the SELECT query i.e. SELECT id FROM table WHERE name='neil'. If a record is returned then you throw an error and don't continue to insert the record.
  17. Thats a bit long winded SemiApocalyptic. To remove anything bar a number you could simply use <?php $string = 'R$100.000,00'; $result = preg_replace('/[^0-9]+/', '', $string); print $result; ?>
  18. Are they stored correctly in your database? Are you using UTF-8 content-type header. Use mysql_query("SET NAMES UTF8"); when conneting to your database.
  19. You should ALWAYS reload the page after an insert or update query. This prevents duplicate entries being inserted or mysql errors if a user ever clicked refresh i.e if($_POST['submit']) { // insert record mysql_query("INSERT INTO ......"); // reload page header("Location:index.php"); exit(); }
  20. try $price = "R$100.000,00"; $price = number_format(str_replace("R$", "", $price), 0, '', ''); print $price;
  21. I think you need individual pages rather than that slider thing with all content on one index template. This is purely for search engine reasons. Get keywords in your meta descriptions, keywords and page titles. I would have more information on each page from each sector i.e. prices from, some sample websites from portfollio with description, some testimonials, etc
  22. Find the most basic solutions to the site requirements and convince the client to go with it. That inspires me to do it as I hate making effing complicated finnecky parts of a website just because a client has seen it done elsewhere and it may not be even the most suitable method. Also get our designer to not go overboard on features. I think I maybe a bit lazy hahaha!
  23. Always check the PHP function manual http://uk2.php.net/manual/en/function.filemtime.php
  24. Use PEAR MAIL::MIME or swiftmailer libraries for sending attachments http://pear.php.net/package/Mail_Mime Not that base64 crap and mail();
  25. The value is contained in the POST array however I would clean the value (remove tags, etc) before placing back into the form field <td><input type="text" name="username" value="<?php print $_POST['username']; ?>" /></td>
×
×
  • 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.