Jump to content

taith

Members
  • Posts

    1,514
  • Joined

  • Last visited

Everything posted by taith

  1. $vars = array(); is completly unnessecary as [code] $vars[] = ''; [/code] works just the same without being told to be an array... its only used as a placeholder for programmers... however, if the $vars is already a string, it will give errors...
  2. yes [code] $files=glob("lib/*.php"); [/code]
  3. easiest function is glob()... takes all the files in a directory, adds them to an array :-D
  4. ie7 has caused more problems of late then any 2 other microsoft products combined... its probably not on your end...
  5. put in the month and year, and it'll tell you how many days are in that month [code] <? function get_daysinmonth($month, $year){ if(checkdate($month, 31, $year)) return 31; elseif(checkdate($month, 30, $year)) return 30; elseif(checkdate($month, 29, $year)) return 29; elseif(checkdate($month, 28, $year)) return 28; return FALSE; } ?> [/code]
  6. nope.... [code] <? $linkoftheday[0] = '<a href="http://nitrofire.net/forum"></a>'; ... $linkoftheday[365] = '<a href="http://nitrofire.net/forum"></a>'; echo $linkoftheday[date(z)]; ?> [/code] every different day will give you a new link... considering that $linkoftheday[#] is set... try it... it'll work :-)
  7. nope! great thing bout arrays $array[]=''; is exactly the same as $array = array(''); are you doing this for day of the week? month? or year... because php date function makes life sooo easy like that week = date(N); <-- 1-7 month = date(j); <-- 1-31 year = date(z); <-- 0-365 [code] <? $linkoftheday[1] = '<a href="http://nitrofire.net/forum">'; $linkoftheday[2] = '<a href="http://nitrofire.net/forum">'; ect... echo $linkoftheday[date(z)]; ?> [/code]
  8. ok... thats just WAY too complicated for what your trying to do... [code] <? $linkoftheday[1] = '<a href="http://nitrofire.net/forum">'; $linkoftheday[2] = '<a href="http://nitrofire.net/forum">'; ect... echo $linkoftheday[getdate()]; ?> [/code]
  9. assuming that the session has started, that should take... and with the if($_SESSION['image_is_logged_in'] =="true"){ }else{ } that really depends on what that var is usually set to...
  10. yup! require_once() just (temporarily) crops all php in the intended file, into the one calling it...
  11. aah... the wonder of arrayed arrays... [code]$result = mysql_query("SELECT * FROM users WHERE `username`='$username' AND `password`='$password' limit 1"); $_SESSION[user]= mysql_fetch_array($result);[/code] then you can access vars like $_SESSION[user][username] personally... i dont use anything but arrayed arrays for holding user info.
  12. the first one checks if the file one intended to attach exists, if it doesnt it emptys $file then it goes through again and see's if $file is empty, if not, it goes ahead and attaches the file. if we did it once, it'd empty the file, and still attach it...
  13. only big difference that would do the same thing... would be changing the [code] if (!empty($file)) [/code] to [code] elseif (!empty($file)) [/code]
  14. nono... those are both necessary [code] <? if ((!empty($file)) && (!file_exists($file))) $file=""; ?> [/code] that takes a look, if someone fills in the $file, but the file doesnt exist, it removes it [code] <? if (!empty($file)) // completly necessary challenge.. ?> [/code] then it goes on to see if the file is still being attached
  15. this might look a little complicated, and its taken me a while to perfect... but its pretty simple... it includes all the headers needed to send emails to almost everywhere :-) [code] <? function get_filename($filepath,$extension=4){ $length = strlen($filepath) - $extension; return substr($filepath,0,$length); } function email($to, $subject="N/A", $text, $from="", $file=""){ if(is_array($to)) $to = implode(", ",$to); if(empty($to)) return FALSE; $subject=strip_tags($subject); $text = wordwrap($text, 77, "<br />\n"); if((!empty($file))&&(!file_exists($file))) $file=""; if(!empty($file)){   switch(get_filetype($file,3)){   case ".rm": $type="audio/x-realaudio"; break;   case ".qt": $type="video/quicktime"; break;   }   switch(get_filetype($file)){   case ".avi": $type="video/avi"; break;   case ".doc": $type="application/msword"; break;   case ".gif": $type="image/gif"; break;   case ".jpg": $type="image/jpeg"; break;   case ".mov": $type="video/mov"; break;   case ".mpg": $type="video/mpeg"; break;   case ".pdf": $type="application/pdf"; break;   case ".png": $type="image/png"; break;   case ".ram": $type="audio/x-pn-realaudio"; break;   case ".tar": $type="application/x-tar"; break;   case ".wav": $type="audio/wav"; break;   case ".zip": $type="application/x-zip-compressed"; break;   }   switch(get_filetype($file,5)){   case ".html": $type="text/html"; break;   case ".mpeg": $type="video/mpeg"; break;   }   if(!isset($type)) $type="text/plain";   $content = fread(fopen($file,"r"),filesize($file));   $content = chunk_split(base64_encode($content));   $name = basename($file); } $uid = strtoupper(md5(uniqid(time()))); $header = "From: $from\nReply-To: $from\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=$uid\n"; $header .= "--$uid\n"; $header .= "Content-Type: text/html\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n"; $header .= "$text\n"; $header .= "--$uid\n"; if(!empty($file)){   $header .= "Content-Type: $type; name=\"$name\"\n";   $header .= "Content-Transfer-Encoding: base64\n";   $header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";   $header .= "$content\n";   $header .= "--$uid--"; } if(mail($to, $subject, $text, $header)) return TRUE; else return FALSE; } ?> [/code]
  16. is it just me? or is this just overkill? [code] while($vis = mysql_fetch_array($hent)){   $overskrift = $vis['side_overskrift'];   $tekst = $vis['side_tekst']; } [/code] and why are you trying to take information from a database that was already passed from the form? [code]<? function forside(){ include('../config_sit00045.php'); $hent = mysql_query("SELECT * FROM forside limit 1"); $vis = mysql_fetch_array($hent); $overskrift = $vis['side_overskrift']; $tekst = $vis['side_tekst']; ?> <form method='POST'> Overskrift: <br /> <TEXTAREA rows="1" cols="40" name="side_overskrift"><?=$_POST[overskrift];?></TEXTAREA> <br /> <br />Tekst: <br /> <TEXTAREA rows="8" cols="75" name="side_tekst"><?=$_POST[tekst];?></TEXTAREA> <br /> <br /><input type='submit' value='Ændre'> </form> <? $hent = mysql_query("SELECT * FROM forside"); $overskrift = $_POST['side_overskrift']; $tekst = $_POST['side_tekst']; $query = mysql_query("UPDATE `forside` SET `side_overskrift` = '".$overskrift."', `side_tekst` = '".$tekst."'"); } ?>[/code] if i understand what your trying to do that is :-)
  17. i've also found this... mysql cannot directly enter $_SESSION variables... also, for some reason, arrays inside arrays...
  18. some hosts that dont have "localhost" mysql databases MAY allow you access from another host... allowing you to potentially have stuff updated to the databases both at once... FYI: dont bother asking the host... just try connecting... they probably dont know...
  19. sorry... i'm not going to be much more help here... i only ever worked with simple php images (stick men(dont laugh ;D))... however you no longer need the whole [code]<? if($im !== false) else echo 'An error occurred.'; ?>[/code] as pictures dont output text the same way :-)
  20. i also wrote this pretty little function [code] <? function filter_charlimit($string, $length="50"){ if(strlen($string)<$length) return $string; else return trim(substr($string, 0, $length)).'...'; } ?> [/code]
  21. [code] $text= "reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreally long word"; wordwrap($text, 20, "<br />\n"); [/code]
  22. [code] <? function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++){   $key .= $pattern{rand(0,62)}; } return $key; } ?> <input type="hidden" name="Userhc15_ProjectNumber" id="Userhc15_ProjectNumber" value="<?=KT_escapeAttribute($row_rshavecopy15['Userhc15_ProjectNumber'])?>"/> <?=randomkeys(10)?> [/code]
×
×
  • 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.