Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Change $p = $_GET['p']; if(is_null($p)) { $p = 0; } To $p = (isset($_GET['p'])) ? $_GET['p'] : 0; The reason your code doesn't work is because $p isn't null. It's assigned the value of $_GET['p']. Although $_GET['p'] may well have been empty, $p has still been assigned it's 'emptyness' hence not null. Regards Huggie
  2. No problem, I wrote it as GET to save me creating a form when developing it. Regards Huggie
  3. With most things, yes, with the mail() function, No! It's standards are as well defined as any of the PHP functions, but the headers parameter that it accepts is what governs which mail servers will happily receive it. However, by posting the code we will be able to see which headers you're currently using. Regards Huggie
  4. Friendly, as promised, working code based on the UK Government Data Standards Catalogue entry for Postcodes. <?php // Get the postcode from the url $postcode = $_GET['postcode']; // Split out any spaces $postcode = str_replace(" ", "", $postcode); // Specify what our areas actually are $areas = array('BR1','BR2','BR3','BR4','BR5','BR6','BR7','BR8','DA1','DA4','DA5','DA6','DA7','DA8','DA14','DA15','DA16','DA17','DA18','SE1','SE2','SE3','SE4','SE5','SE6','SE7','SE8','SE9','SE10','SE11','SE12','SE13','SE14','SE15','SE16','SE17','SE18','SE19','SE20','SE21','SE22','SE23','SE24','SE25','SE26','SE27','SE28','SW2','SW4','SW8','SW9','SW11','SW12','SW16','SW17','SW18','CR0','CR2','CR4','CR7','CR8'); // Use length to help check the different formats for UK postcodes $char = strlen($postcode); if (($char == 5) && preg_match('/([a-z]\d)\d[a-z]{2}/', $postcode, $matches)){ // S1 2AB if (in_array(strtoupper($matches[1]), $areas)){ $match = 1; } } elseif (($char == 6) && preg_match('/([a-z]{2}\d)\d[a-z]{2}/i', $postcode, $matches)){ // BR1 2AB if (in_array(strtoupper($matches[1]), $areas)){ $match = 1; } } elseif (($char == 6) && preg_match('/([a-z]{1}\d{2})\d[a-z]{2}/i', $postcode, $matches)){ // S12 3AB if (in_array(strtoupper($matches[1]), $areas)){ $match = 1; } } elseif (($char == 7) && preg_match('/([a-z]{2}\d{2})\d[a-z]{2}/i', $postcode, $matches)){ // BR12 3AB if (in_array(strtoupper($matches[1]), $areas)){ $match = 1; } } elseif (($char == 7) && preg_match('/([a-z]{2}\d[a-z])\d[a-z]{2}/i', $postcode, $matches)){ // SW1W 2AB if (in_array(strtoupper($matches[1]), $areas)){ $match = 1; } } else { echo "Sorry, your postcode appears to be invalid"; exit(); } // Echo the output to the screen if ($match){ echo "Congratulations, " . strtoupper($matches[1]) . " is in our area<br>\n"; } else { echo "Sorry, " . strtoupper($matches[1]) . " isn't in our area<br>\n"; } ?> Regards Huggie
  5. There were form tags in the PHP code, I know, I changed them! I only added a 'name' element to the relevant form tag though, and then changed the javascript to look at that field. It all works here. Regards Huggie
  6. I'll take a look at this a little later this morning if I get the chance. Regards Huggie
  7. Working fine! I must have pasted it incorrectly. Thanks mate Don't forget, you'll need to do some validation on this first, as if I entered my postcode as BR21 then it'd tell me it's in your area, even though it's actually not as it's only looking at the first three characters. Regards Huggie
  8. OK, try with the attached files. Regards Huggie [attachment deleted by admin]
  9. Check you've copied and pasted it correctly, as I've just checked it and it works. Regards Huggie
  10. Call me old fashioned, but I'd say that means it doesn't work. Try changing the query to this... mysql_query("INSERT INTO albums (album_id,album_name, album_desc,album_cover) VALUES ('0', 'Peter', 'Griffin' , 'yes')") or die (mysql_error()); Regards Huggie
  11. Try this... <?php // Set the areas you cover $areas = array('BR1','BR2','BR3'); // Get the postcode from the form $postcode = strtoupper($_POST['postcode']); // Check the areas against the postcode entered if (in_array(substr($postcode, 0, 3), $areas)){ echo "$postcode is in area!!!"; } else { echo "Sorry, the postcode $postcode is outside of our work region"; } ?> This is basic and will need lots more validation. Regards Huggue
  12. It is, but it looks as though you want to know so you can create tabular data in columns. If so then there's loads of posts on here about it, just search these forums. Regards Huggie
  13. Your PHP file is incorrect, but not because the php's incorrect, but your html field names aren't correct. That's why it's not working. Can you post the full code for your page? Regards Huggie
  14. If you're using MySQL then make your insert using mysql_query() and then straight after, use mysql_insert_id() <?php if ($r = mysql_query("INSERT INTO product_table VALUES ('something','something')")){ header('Location: product.php?product_id=' . mysql_insert_id($r)); } ?> Regards Huggie
  15. Something like this should work (Untested)... <?php // Maximum posts to show $show = 25; // Run the query and assign the total rows to a variable $r = mysql_query("SELECT count(`id`) FROM `table`"); $total = mysql_result($r, 0, 0); // Set the true offset if the value is less than 0 $offset = ($total - $show < 0) ? 0 : $total - $show; // Run the query with the offset $r = mysql_query("SELECT * FROM `table` ORDER BY id LIMIT $offset, $show"); // Then process $r as you were before ?> Regards Huggie
  16. I can't see that, I guess it's a member only feature. You can do it, but you'd need more than one query, that's all. Regards Huggie
  17. OK, well the tagbox here shows the newest messages at the top of the box! Which would be "SELECT * FROM table ORDER BY id DESC LIMIT 25". If you wanted it the other way around then you'd need to use this more than one query. Regards Huggie
  18. What columns are in your database? Huggie
  19. If you're ordering by ID (Assuming that id is auto incrementing) then use DESC Regards Huggie
  20. Newest comment first is DESC (Descending) not ASC (Ascending). Rergards Huggie
  21. In that case you can pretty much ignore all the permissions stuff I believe as Windows doesn't implement it properly. Regards Huggie
  22. Alternatively just drop an onClick event in <button name="delete" value="delete" onClick="location.href='http://www.google.co.uk'">Delete</button> Regards Huggie
  23. Oh I see. Why not just create an image and use that as a hyperlink? Huggie
  24. OK, well mark this topic as solved by using the 'Topic Solved' button and start a new thread for that question. Regards Huggie :-)
  25. I'm based in the UK and I'll PM you from here on in... Regards Huggie
×
×
  • 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.