Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. by any chance are ya encasing the 1 or 0 in quotes, like a literal string? if so that wud be a problem
  2. LOL okay yer right, i think it's the leap years. anyone want to use julian calander functions instead?
  3. how about echo intval(time()-strtotime("1968-12-31"))/(60*60*24*7*52)); the formula time returns amt of seconds thus (secs per min* mins per hr * hrs per day * days per week * weeks per year);
  4. U are safe, the time function isn't reliant on the users timezone. but how the server was setup. usually the servers timezone so no matter who uses it, they will see the servers time
  5. cudn have said it any better... BTW nice tiara
  6. U tell it how to get the data, but you never tell it when to get the data. u have to use one of the several functions mysql_result mysql_fetch_array mysql_fetch_row mysql_fetch_assoc to retrieve rows after a mysql_query.
  7. Okay, thanks, makes sense now it's a great tip, and much thanks for the info
  8. Hey PFMaBiSmAd, I noticed ya said which just brings up a question instead of redirection, cudn the FORM ACTION add a GET paramter with a random number. so it always thinks it's a different page?
  9. WHERE task_id IN (x,y,z) u put use the IN function which works like an OR operator UPDATE tasks SET status=1 WHERE task_id=x OR task_id=y OR task_id=z
  10. not working? <?php if($_SERVER['REQUEST_METHOD']=='POST') echo "<PRE>". print_r($_POST,true) ."</PRE>"; ?> <html> <body> <form method="POST"> <INPUT TYPE='checkbox' name='cb[]' value='0'> <INPUT TYPE='checkbox' name='cb[]' value='1'> <INPUT TYPE='checkbox' name='cb[]' value='2'> <INPUT TYPE='checkbox' name='cb[]' value='3'> <INPUT TYPE='checkbox' name='cb[]' value='4'> <INPUT type="submit"> </FORM> </body> </html> as i said, unchecked checkboxed return nothing, while checked boxes return the value.
  11. yep, as thorpe suggests mkdir returns true or false. depending if it succeeded or not. so there is no need to use other functions (is_dir) to check if it succeeeded. since it returns a numeric, ya can use it as an expression (if,while,switch). you will find a lot of functions that return simple information like this, so is of great use.
  12. keep the [] in the form makes it easier to process [] will return an array, and the function u posted will handle numerics or strings so build a function function createhidden($post,$inp='') { foreach($post as $key => $val) { if(is_array($val)) createhidden($val,$key); else { $val=htmlentities(stripslashes(strip_tags($val))); echo '<INPUT TYPE=HIDDEN name="' . (!empty($inp)?"$inp\[\]":$key) . "\" VALUE=\"$val\">\n"; } } notice it calls itself on arrays so ya can call it up as createhidden($_POST);
  13. nope. checkboxes return nothing, if unchecked or something if checked (as a value can be attached to the tag) so $mycheckbox=isset($_POST['mycheckbox'])?1:0;
  14. laffin

    Data..

    echo "<PRE>" . htmlspecialchars($row) . "</PRE>";
  15. <?php $mywordlinks = array( 'adam' => 'http://www.adam.com', 'eve' => 'http://www.eve.com', 'apples' => 'http://www.apple.com' ); function ismyword($matches) { global $mywordlinks; $word=$matches[1]; if(isset($mywordlinks[$key=strtolower($word)])) { $word="<A HREF='$mywordlinks[$key]'>$word</A>"; } return $word; } $string="Adam went to the supermarket to find apples, but there was only bananas! I feel sorry for Adam, don't you?"; $newstring=preg_replace_callback("@(?=[ ]?)([a-z\']{3,})(?=[\s\.,?!])@im",'ismyword',$string); echo "<PRE>$string\n$newstring</PRE>"; ?>
  16. one of 2 ways // U can do this $res=mysql_query('SELECT COUNT(*) FROM users'); echo mysql_result($res,0,0); echo '<BR>'; // or U can do this $$res=mysql_query('SELECT * FROM users'); echo mysql_num_rows($res);
  17. u can always set a cookie with the page user is on like a tracking cookie. now at beginning of some scripts, that shudn be refreshed check the cookie against the script name, if they are the same, most likely a refresh. redirect user to other page just a thought
  18. until it's outputted? why cant u insert the routine before/during the output? if that can't be done, consider using ob_start/ob_get_contents/ob_clean functions. which will capture the output into a string, than ya can process and echo it out.
  19. laffin

    Extract Data

    maybe sumfin like $pat='~Del Date/Time:.*<b>(\d{2}/\d{2}\d{2}~ims'
  20. // establish entered date variables $eYear = $_POST['eYear']; $eDay = $_POST['eDay']; $eMonth = $_POST['eMonth']; $eDate=strtotime("$eYear-$eDay-$eMonth"); // get current date turn it into variables $curDate = time(); // combine dates into a long string if ($curDate < $eDate) { // show error } converting to a numeric format simplifies the check. thus reason for using time()
  21. as he said, javascrpt can be bypassed. reason it shud not be relied on for validation. look at the popular firefox extension, Greasemonkey, which can remove / replace javascript from web pages. and still report that javascript is enabled. Javascript can be used to make it easier for the end user, those that behave. for the rest dun forget php validation. as to the post by haku, yep, but ya dun wanna use $_POST in yer html form either, another infraction of possible exploiting the code. use the local variables. if u have validated / santized them. if(isset($_POST['username'] && preg_match("@^\w+$@i",$username,$matches) && strlen($_POST['username']) < 30) $username=$_POST['username']; than in yer html <input type="text" name="somename" value="<?php echo $username;>"; ?>" />
  22. does yer script force u to use 2 arrays for available and unavailable. seems like a waste if it does, when u can have the dates, with flags. A multi-dimensional array. which wud cut down on the code, u may also want to keep things in time() format as that makes comparisons much simpler. $today=strtotime("Y-m-D"); for($i=0;$i<5;$i++) $fdays[strtotime("+$i days",$today)]=true; than get yer unavailable days, in the array. then mark the days which are unavailble for($udays as $day) { $dt = strtotime($day); if(isset($fdays[$dt])) $fdays[$dt]=false; } now the array $fdays, have a value of true or false true = available false = unavaliabe foreach($fdays as $key => $value) { echo date("Y-m-d,$key) . " is " . ($value ? "":"un") . "available"; }
  23. <?php function array_datetotoday($startdate) { $ldate=strtotime($startdate); $edate=strtotime(date("Y-m")); do { $dates[]=date("Y-m",$ldate); $ldate=strtotime("+1 Month",$ldate); }while($ldate <= $edate); return $dates; } $date_array = array_datetotoday(date("Y-m",strtotime("-1 Year"))); foreach($date_array as $dt) echo "$dt<br>"; ?>
  24. $hk shud be $get. the query itself could be written as $query = "SELECT pimp,hoeskilled FROM `{$tab[pimp]}` WHERE `rid`=$rid ORDER BY hoeskilled DESC"; since now ya got # of hoes killed in a descending order, all u need is the first row. you can add images to the html like $tcount=1; while ($row = mysql_fetch_assoc($get)){ $image=(($tcount<=10) ? $tcount:"default") . ".png"; echo "<a href=\"\"onMouseover=\"popup('<span class=styleGreen>Hoe Killer</span><br/>')\"; onMouseout=\"\kill()\"><img src='images/$image' width='16' height='16' alt='killer award' border='0'></a>"; } now all u need are the top10 png images, and a default images. top1.gif - top10.gif
  25. the code wont work as well cuz the 2nd if statement, invalidated the POST fields, when $query is set, it will be set with blank values if(isset($_POST['timeout']) && (time() > $_POST['timeout'])) { will fix that extra paren issue
×
×
  • 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.