Welcome Guest [Log In] [Register]
Add Reply
PHP / Undefined indexes and variables
Topic Started: May 17 2009, 10:08 AM (742 Views)
Knight13

0
Edited by Knight13, Mar 19 2010, 07:00 AM.
Offline Profile Quote Post Goto Top
 
Darksorrow131

Can you put some short example code that triggers the error?
(let loop () (loop))
((lambda (x) (x x)) (lambda (x) (x x)))
(let ((k #f)) (call/cc (lambda (cc) (set! k cc)) (k))
((call/cc call/cc) (call/cc call/cc))

-- Infinite loops are awesome! --
Tell me if you have other awesome infinite loops!
Offline Profile Quote Post Goto Top
 
Knight13

0
Edited by Knight13, Mar 19 2010, 07:00 AM.
Offline Profile Quote Post Goto Top
 
Darksorrow131

So I guess $_GET doesn't have a 'start' value in it?
(let loop () (loop))
((lambda (x) (x x)) (lambda (x) (x x)))
(let ((k #f)) (call/cc (lambda (cc) (set! k cc)) (k))
((call/cc call/cc) (call/cc call/cc))

-- Infinite loops are awesome! --
Tell me if you have other awesome infinite loops!
Offline Profile Quote Post Goto Top
 
Knight13

0
Edited by Knight13, Mar 19 2010, 07:00 AM.
Offline Profile Quote Post Goto Top
 
Ryan

The index you're using on the $_GET superglobal isn't defined?
Offline Profile Quote Post Goto Top
 
Darksorrow131

Basically $_GET grabs the corresponding value off the URL's query string, so if you visit "firstpage.php", it doesn't have a value called 'start', so it's an error. If you visit "firstpage.php?start=5", then there is such a value, and $_GET['start'] would return 5 instead of being an error.
(let loop () (loop))
((lambda (x) (x x)) (lambda (x) (x x)))
(let ((k #f)) (call/cc (lambda (cc) (set! k cc)) (k))
((call/cc call/cc) (call/cc call/cc))

-- Infinite loops are awesome! --
Tell me if you have other awesome infinite loops!
Offline Profile Quote Post Goto Top
 
Ryan

Do it like this?
if ( isset ($_GET["var"]) ) {
$var = $_GET["var"];
};
Offline Profile Quote Post Goto Top
 
Knight13

0
Edited by Knight13, Mar 19 2010, 07:01 AM.
Offline Profile Quote Post Goto Top
 
Darksorrow131

It's basically the same as what Ryan wrote - you check the existence before actually using it.
(let loop () (loop))
((lambda (x) (x x)) (lambda (x) (x x)))
(let ((k #f)) (call/cc (lambda (cc) (set! k cc)) (k))
((call/cc call/cc) (call/cc call/cc))

-- Infinite loops are awesome! --
Tell me if you have other awesome infinite loops!
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Web-Based Programming Support · Next Topic »
Add Reply

Banner and Logo by TheKeith