Jump to content

silkfire

Members
  • Posts

    569
  • Joined

  • Last visited

Everything posted by silkfire

  1. What browser are you using?
  2. Hackalive did you ever try my solutions?
  3. Shouldn't 01:08:34 be rounded to 01:15?
  4. To properly destroy a session, you do like this: $_SESSION = array(); To properly destroy a cookie, set the cookie again but with time somewhere in the past, for example -30 days ago.
  5. Mate you must've missed the basics of performing a fetch query in PHP. This: mysql_query("SELECT * FROM Aircraft_Daily_Status"); will give you nothing because you haven't assigned the result of that query to a variable. Do like this instead: $query = mysql_query('SELECT `Schedule`, `EMMA` FROM `Aircraft_Daily_Status` WHERE `Aircraft`= \'8Q-OEQ\''); list($OEQ_Sched, $OEQ_EMMA) = mysql_fetch_row($query); ?> <td id="cell2display"><?=$OEQ_Sched?></td> <td id="cell3display"><?=$OEQ_EMMA?></td>
  6. Hello Kanye To open a worksheet you need Microsoft Excel, it costs about $119.00. You can upload the Excel worksheet to PHPMyAdmin and that will insert all its data into a database table. Hope that was helpful?
  7. Start by removing: if (is_null($birthYear)){ $ageRange = 'unknown'; } from the end of the function. Then at the start of the function, add: if (empty($birthYear)) return 'unknown'; Piece a pie!
  8. By the way, the reason that didn't trigger was because you're still supplying a birth year, in this case an empty string. If you call your function with no arguments, THEN the default value is 1970: echo getAgeRange();
  9. Look, Debbie. NULL values from a database are transformed into empty strings ('') upon retrieval. Also, '' is converted to 0 when using arithmetics. This line right here $estimatedAge = ($currYear - $birthYear - 1); is interpreted like this by PHP: $estimatedAge = 2012 - 0 - 1; Which in turn is 2011. If a person is 2011 years old no wonder he's senior!
  10. jQuery is a subset of JS. Any jQuery code is also JavaScript code, but not necessarily vice versa.
  11. You showed us the function definition. It's like buying concert tickets and not going to the concert.
  12. That's JavaScript code made, whom are you trying to fool?
  13. 1. That little function will help you maybe in 70% of cases. By the way who uses eregi these days? Here's a robust "Is this a valid email?" function that honors all the rules of a valid email address according to RFC 5322 (sections 3.2.3 and 3.4.1) and RFC 5321 - with a more readable form given in the informational RFC 3696. function is_valid_email_address($email_address) { #################################################################################### # # NO-WS-CTL = %d1-8 / ; US-ASCII control characters # %d11 / ; that do not include the # %d12 / ; carriage return, line feed, # %d14-31 / ; and white space characters # %d127 # ALPHA = %x41-5A / %x61-7A ; A-Z / a-z # DIGIT = %x30-39 $no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]"; $alpha = "[\\x41-\\x5a\\x61-\\x7a]"; $digit = "[\\x30-\\x39]"; $cr = "\\x0d"; $lf = "\\x0a"; $crlf = "(?:$cr$lf)"; #################################################################################### # # obs-char = %d0-9 / %d11 / ; %d0-127 except CR and # %d12 / %d14-127 ; LF # obs-text = *LF *CR *(obs-char *LF *CR) # text = %d1-9 / ; Characters excluding CR and LF # %d11 / # %d12 / # %d14-127 / # obs-text # obs-qp = "\" (%d0-127) # quoted-pair = ("\" text) / obs-qp $obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]"; $obs_text = "(?:$lf*$cr*(?:$obs_char$lf*$cr*)*)"; $text = "(?:[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|$obs_text)"; # # there's an issue with the definition of 'text', since 'obs_text' can # be blank and that allows qp's with no character after the slash. we're # treating that as bad, so this just checks we have at least one # (non-CRLF) character # $text = "(?:$lf*$cr*$obs_char$lf*$cr*)"; $obs_qp = "(?:\\x5c[\\x00-\\x7f])"; $quoted_pair = "(?:\\x5c$text|$obs_qp)"; #################################################################################### # # obs-FWS = 1*WSP *(CRLF 1*WSP) # FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space # obs-FWS # ctext = NO-WS-CTL / ; Non-white space controls # %d33-39 / ; The rest of the US-ASCII # %d42-91 / ; characters not including "(", # %d93-126 ; ")", or "\" # ccontent = ctext / quoted-pair / comment # comment = "(" *([FWS] ccontent) [FWS] ")" # CFWS = *([FWS] comment) (([FWS] comment) / FWS) # # note: we translate ccontent only partially to avoid an infinite loop # instead, we'll recursively strip *nested* comments before processing # the input. that will leave 'plain old comments' to be matched during # the main parse. # $wsp = "[\\x20\\x09]"; $obs_fws = "(?:$wsp+(?:$crlf$wsp+)*)"; $fws = "(??:(?:$wsp*$crlf)?$wsp+)|$obs_fws)"; $ctext = "(?:$no_ws_ctl|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])"; $ccontent = "(?:$ctext|$quoted_pair)"; $comment = "(?:\\x28(?:$fws?$ccontent)*$fws?\\x29)"; $cfws = "(??:$fws?$comment)*(?:$fws?$comment|$fws))"; # # these are the rules for removing *nested* comments. we'll just detect # outer comment and replace it with an empty comment, and recurse until # we stop. # $outer_ccontent_dull = "(?:$fws?$ctext|$quoted_pair)"; $outer_ccontent_nest = "(?:$fws?$comment)"; $outer_comment = "(?:\\x28$outer_ccontent_dull*(?:$outer_ccontent_nest$outer_ccontent_dull*)+$fws?\\x29)"; #################################################################################### # # atext = ALPHA / DIGIT / ; Any character except controls, # "!" / "#" / ; SP and specials. # "$" / "%" / ; Used for atoms # "&" / "'" / # "*" / "+" / # "-" / "/" / # "=" / "?" / # "^" / "_" / # "`" / "{" / # "|" / "}" / # "~" # atom = [CFWS] 1*atext [CFWS] $atext = "(?:$alpha|$digit|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])"; $atom = "(?:$cfws?(?:$atext)+$cfws?)"; #################################################################################### # # qtext = NO-WS-CTL / ; Non white space controls # %d33 / ; The rest of the US-ASCII # %d35-91 / ; characters not including "\" # %d93-126 ; or the quote character # qcontent = qtext / quoted-pair # quoted-string = [CFWS] # DQUOTE *([FWS] qcontent) [FWS] DQUOTE # [CFWS] # word = atom / quoted-string $qtext = "(?:$no_ws_ctl|[\\x21\\x23-\\x5b\\x5d-\\x7e])"; $qcontent = "(?:$qtext|$quoted_pair)"; $quoted_string = "(?:$cfws?\\x22(?:$fws?$qcontent)*$fws?\\x22$cfws?)"; # # changed the '*' to a '+' to require that quoted strings are not empty # $quoted_string = "(?:$cfws?\\x22(?:$fws?$qcontent)+$fws?\\x22$cfws?)"; $word = "(?:$atom|$quoted_string)"; #################################################################################### # # obs-local-part = word *("." word) # obs-domain = atom *("." atom) $obs_local_part = "(?:$word(?:\\x2e$word)*)"; $obs_domain = "(?:$atom(?:\\x2e$atom)*)"; #################################################################################### # # dot-atom-text = 1*atext *("." 1*atext) # dot-atom = [CFWS] dot-atom-text [CFWS] $dot_atom_text = "(?:$atext+(?:\\x2e$atext+)*)"; $dot_atom = "(?:$cfws?$dot_atom_text$cfws?)"; #################################################################################### # # domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS] # dcontent = dtext / quoted-pair # dtext = NO-WS-CTL / ; Non white space controls # # %d33-90 / ; The rest of the US-ASCII # %d94-126 ; characters not including "[", # ; "]", or "\" $dtext = "(?:$no_ws_ctl|[\\x21-\\x5a\\x5e-\\x7e])"; $dcontent = "(?:$dtext|$quoted_pair)"; $domain_literal = "(?:$cfws?\\x5b(?:$fws?$dcontent)*$fws?\\x5d$cfws?)"; #################################################################################### # # local-part = dot-atom / quoted-string / obs-local-part # domain = dot-atom / domain-literal / obs-domain # addr-spec = local-part "@" domain $local_part = "(($dot_atom)|($quoted_string)|($obs_local_part))"; $domain = "(($dot_atom)|($domain_literal)|($obs_domain))"; $addr_spec = "$local_part\\x40$domain"; # # this was previously 256 based on RFC3696, but dominic's errata was accepted. # if (strlen($email_address) > 254) return 0; # # now match what's left # if (!preg_match("!^$addr_spec$!", $email_address, $m)) return 0; $bits = array( 'local' => isset($m[1]) ? $m[1] : '', 'local-atom' => isset($m[2]) ? $m[2] : '', 'local-quoted' => isset($m[3]) ? $m[3] : '', 'local-obs' => isset($m[4]) ? $m[4] : '', 'domain' => isset($m[5]) ? $m[5] : '', 'domain-atom' => isset($m[6]) ? $m[6] : '', 'domain-literal' => isset($m[7]) ? $m[7] : '', 'domain-obs' => isset($m[8]) ? $m[8] : '', ); # # length limits on segments # if (strlen($bits['local']) > 64) return 0; if (strlen($bits['domain']) > 255) return 0; # # restrictions on domain-literals from RFC2821 section 4.1.3 # # RFC4291 changed the meaning of :: in IPv6 addresses - i can mean one or # more zero groups (updated from 2 or more). # if (strlen($bits['domain-literal'])) { $Snum = "(\d{1,3})"; $IPv4_address_literal = "$Snum\.$Snum\.$Snum\.$Snum"; $IPv6_hex = "(?:[0-9a-fA-F]{1,4})"; $IPv6_full = "IPv6\:$IPv6_hex(?:\:$IPv6_hex){7}"; $IPv6_comp_part = "(?:$IPv6_hex(?:\:$IPv6_hex){0,7})?"; $IPv6_comp = "IPv6\$IPv6_comp_part\:\:$IPv6_comp_part)"; $IPv6v4_full = "IPv6\:$IPv6_hex(?:\:$IPv6_hex){5}\:$IPv4_address_literal"; $IPv6v4_comp_part = "$IPv6_hex(?:\:$IPv6_hex){0,5}"; $IPv6v4_comp = "IPv6\(?:$IPv6v4_comp_part)?\:\?:$IPv6v4_comp_part\?)$IPv4_address_literal"; # # IPv4 is simple # if (preg_match("!^\[$IPv4_address_literal\]$!", $bits['domain'], $m)){ if (intval($m[1]) > 255) return 0; if (intval($m[2]) > 255) return 0; if (intval($m[3]) > 255) return 0; if (intval($m[4]) > 255) return 0; } else { # # this should be IPv6 - a bunch of tests are needed here # while (1) { if (preg_match("!^\[$IPv6_full\]$!", $bits['domain'])) break; if (preg_match("!^\[$IPv6_comp\]$!", $bits['domain'], $m)){ list($a, $b) = explode('::', $m[1]); $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b"; $groups = explode(':', $folded); if (count($groups) > 7) return 0; break; } if (preg_match("!^\[$IPv6v4_full\]$!", $bits['domain'], $m)){ if (intval($m[1]) > 255) return 0; if (intval($m[2]) > 255) return 0; if (intval($m[3]) > 255) return 0; if (intval($m[4]) > 255) return 0; break; } if (preg_match("!^\[$IPv6v4_comp\]$!", $bits['domain'], $m)){ list($a, $b) = explode('::', $m[1]); $b = substr($b, 0, -1); # remove the trailing colon before the IPv4 address $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b"; $groups = explode(':', $folded); if (count($groups) > 5) return 0; break; } return 0; } } } else { # # the domain is either dot-atom or obs-domain - either way, it's # made up of simple labels and we split on dots # $labels = explode('.', $bits['domain']); # # this is allowed by both dot-atom and obs-domain, but is un-routeable on the # public internet, so we'll fail it (e.g. user@localhost) # if (count($labels) == 1) return 0; # # checks on each label # foreach ($labels as $label){ if (strlen($label) > 63) return 0; if (substr($label, 0, 1) == '-') return 0; if (substr($label, -1) == '-') return 0; } # # last label can't be all numeric # if (preg_match('!^[0-9]+$!', array_pop($labels))) return 0; } return true; } 2. Make an array with strings that you want to restrict then loop and check against that array whether name contains any of those strings. Remember the spammer may use punctuation and spaces to fool your validation. For this reason you can clean the name first by removing everything except letters.
  14. I know PDO has Exception handling that you can catch. Is a way of gracefully taking care of errors, before spitting them out at the user. Not sure if mysql_ driver has Exception handling.
  15. Indeed. That very line of code is the reason why the first record is skipped. And $id = $array[id]; $quote = $array[quote]; $person = $array[person]; Why are you renaming variables that you echo in the very following statement? Plus those array keys ([id]] need quotes inside them, like this: ['id'].
  16. if (!isset($birthYear)) {} should be the first line in that function, not last. But it's best to use "if empty($birthYear)" instead, because '' is still a variable and it's set. 0 and '' (empty string) evaluate TRUE for empty().
  17. Why not use AJAX and JavaScript? I mean the button is on the client side, not server?
  18. Show us the code where you call the isUsernameAvailable() function instead.
  19. Or Spreadsheet_Excel_Writer, which is much faster but creates XLS in the older xls format.
  20. Do you have errors enabled?
  21. Shouldn't PDO::quote be adding the quotes? It only escapes any existing quotes, doesn't add them =)
  22. Yeah that was pretty obvious mate You need quotes around your variables. Non-qoutes only work with numbers: $DB->query("INSERT INTO user (email_address, password, user_level, name, membership_type, join_date) VALUES ('$quoted_email', '$encoded_password', '1', '$quoted_name', '$quoted_membership_type', '$register_date')");
  23. Where do you ever define $DB? And SafePDOCOE(db_name); Shouldn't that be written as $DB = SafePDOCOE(db_name);, I mean it returns something, right?
  24. What do you mean by "separate"?
  25. Remind me again why you're using the quote function with PDO?
×
×
  • 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.