Jump to content

tangar

Members
  • Posts

    10
  • Joined

  • Last visited

tangar's Achievements

Member

Member (2/5)

0

Reputation

  1. Great Now I understand the picture THANK YOU, GUYS! :DDD
  2. So it's not somekind of acronym, just random glyph were chosen? I thought there is somekind of riddle. Like 'i' for iteration or something like this...
  3. Sorry for silly question, I tried to google it, but can't find an answer Why there: date('d-m-Y H:i:s') 'i' means minutes? It has to be 'm', but there is 'month' already, ok.. What does acronym 'i' stands for there? :DD Which word hides behind this glyph? Thanks.
  4. Big thanks! After hour or so I finally fixed it: $visitCounter = 0; if (isset($_COOKIE['visitCounter'])) { $visitCounter = $_COOKIE['visitCounter']; ++$visitCounter; } $lastVisit = ''; if (isset($_COOKIE['lastVisit'])) { $lastVisit = date('d-m-Y H:i:s', $_COOKIE['lastVisit']); if (date('d-m-Y', $_COOKIE['lastVisit']) != date('d-m-Y')) { setcookie("visitCounter", $visitCounter); setcookie("lastVisit", time()); } } else { setcookie("lastVisit", time()); setcookie("visitCounter", $visitCounter); } Is it possible to make it better? I feel that my solution is quite crude hehe :E~~
  5. requinix, thank you. I got some mistakes with style cause I changed this code a lot to make it work, but failed... The problem there - not intendation; although next time I'll try to format code more carefully before posting somewhere. cyberRobot, thanks, but could you be more precise? I know the difference for 'if' with {} and without. I tried several ways fix my code, but it doesn't work. I wrote another version of this program and it works. The question - how to make this particular code to work and understand it works such weird - to solve this riddle, this mistery. I'm rookie, learning PHP from books and it's important to understand such details. Please, help! Problem still unsolved.
  6. Thanks, but I have proper indentation - when I pasted it at forum, it didn't save. Donno why. I copy again: $visitCounter = 0; if (isset($_COOKIE['visitCounter'])) { $visitCounter = $_COOKIE['visitCounter']; $visitCounter++; } $lastVisit = ''; if (isset($_COOKIE['lastVisit'])) $lastVisit = date('d-m-Y H:i:s', $_COOKIE['lastVisit']); if (date('d-m-Y', $_COOKIE['lastVisit']) != date('d-m-Y')) { setcookie("visitCounter", $visitCounter, 0x7FFFFFFF); setcookie("lastVisit", time(), 0x7FFFFFFF); } Problem is still there, I got errors; without error reporting it works. Please help!
  7. $visitCounter = 0; if (isset($_COOKIE['visitCounter'])) { $visitCounter = $_COOKIE['visitCounter']; $visitCounter++; } $lastVisit = ''; if (isset($_COOKIE['lastVisit'])) $lastVisit = date('d-m-Y H:i:s', $_COOKIE['lastVisit']); if (date('d-m-Y', $_COOKIE['lastVisit']) != date('d-m-Y')) { setcookie("visitCounter", $visitCounter, 0x7FFFFFFF); setcookie("lastVisit", time(), 0x7FFFFFFF); } output: if ($visitCounter == 1) echo 'Welcome, new friend!'; else echo 'This is your '.$visitCounter.' visit. Your last visit was at '.$lastVisit.'. Nice to see you again!'; If I got: error_reporting(E_ALL); ini_set('display_errors', '1'); I got errors: Notice: Undefined index: lastVisit in C:\OpenServer\domains\localhost\php\cookie.inc.php on line 10 Warning: Cannot modify header information - headers already sent by (output started at C:\OpenServer\domains\localhost\php\cookie.inc.php:10) inC:\OpenServer\domains\localhost\php\cookie.inc.php on line 11 Warning: Cannot modify header information - headers already sent by (output started at C:\OpenServer\domains\localhost\php\cookie.inc.php:10) inC:\OpenServer\domains\localhost\php\cookie.inc.php on line 12 This is your 0 visit. Your last visit was at . Nice to see you again! If I delete error reporting - it works! Please help - how to make this script work with error reporting? Thanks!
  8. hi ho! I'm rookie and wanna create count function from zero as training (just to learn some stuff about arrays). What I got: <? $menu = array ( array('link'=>'Magic', 'href'=>'9.php'), array('link'=>'Poker', 'href'=>'10.php'), array('link'=>'Number', 'href'=>'11.php'), array('link'=>'Count', 'href'=>'12.php'), array('link'=>'Size', 'href'=>'13.php') ); function myCount ($count, $mode=0) { // mode - if it would be multidimensional array if (is_array($count)){ $b=0; // if array would be empty foreach ($count as $a) { if (is_array($a) and $mode==1) $b += myCount($a, 1); $b++; } } elseif (is_null($count)){ $b = 0; } else { $b = 1; } print "$b"; } myCount ($menu, 1); ?> It counts normal arrays ok, but it counts too much with multidimensional. To count them I'm making recursion, but it seems it doesn't work corrent; aswer is '222225' lol Please help!
  9. ginerjm, thank you very much! I though I had all errors on, but it seems NOTICE was off. With this: error_reporting(E_ALL); ini_set('display_errors', '1'); I saw notices: So I understand that got troubles with forms. And after I worked some time, I noticed that I got silly error: $guess = $_POST['$guess']; It has to be: $guess = $_POST['guess']; So, what I got now, it works as intended: https://hastebin.com/dedoqixahu.http Thank you, guys!
  10. Hello! I'm rookie. Please help me to solve problem with storing stuff in hidded fields for 'Guess a number' program: https://hastebin.com/vomasuvere.xml Why this... if ($choice == 'big'){ print $guess[1]=($guess[0] / 2); } elseif ($choice == 'small') { print $guess[2]=($guess[0] + 25); ...doesn't work? p.s. I know that it's the worst decision to use arrays and hidden fields in such program; but I've made decision to make it like this and can't drop it Please help! p.p.s. This is my live stream, how I made this program - https://www.youtube.com/watch?v=lLQ4J2JkO60
×
×
  • 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.