The error i'm having is : Notice: Undefined index: hasStarted in C:\xampp\htdocs\test\random.php on line 3
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.
(04-02-2017, 01:27 PM)Vi-Sion Wrote: The error i'm having is : Notice: Undefined index: hasStarted in C:\xampp\htdocs\test\random.php on line 3
Your problem is written in plain english "Undefined index: hasStarted in C:\xampp\htdocs\test\random.php on line 3"
You are trying to access the variable $_SESSION["hasStarted"] but is is not set.
You can check if a variable is set with the method isset()
well i know but i heard that in php you don't need to assign a value to a variable before using it.
Code:
In PHP the type of the variable does not need to be declared before use it because types are associated with values rather than variables.
this is quoted from w3resource .
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.
i also heard it takes a default value if i didn't give it one so if used as a boolean and didn't give it a value it's default value should be false
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.
(04-02-2017, 01:55 PM)Vi-Sion Wrote: i also heard it takes a default value if i didn't give it one so if used as a boolean and didn't give it a value it's default value should be false
Yes. In php an unset variable will always give you false.
But in your code, you are trying to access a variable index, that will always trow you an error if it is unset.
(This post was last modified: 04-02-2017, 02:10 PM by Pikami.)
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.
<?php
$_SESSION["tries"]=0;
}
else{?>
<script><?php if($_SESSION["number"]<$_POST["number"]){?>alert("Hidden number is smaller");<?php }?></script>
<script><?php if($_SESSION["number"]>$_POST["number"]){?>alert("Hidden number is bigger");<?php } ?></script>
<?php }} ?>
</body>
</html>
Everyone should learn how to code, it teaches you how to think.
You don't have to be a Genius to know how to code you just need to be determined.
The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.