Help with undefined index in PHP?-Collection of common programming errors
programming-amp-design Retrieving original web address
discoverer: anonymous Helo, I have a little problem, How can I define index “pagina” in php because I have a script in PHP and show me a error: “Notice: Undefined index: pagina in……. on line 51” where on line 51 is: “$pagina = $_GET[‘pagina’];”
Thank you
- You could define it in a form or query string (like: index.php?pagina=1), but you should probably also change the code on line 51 to: $pagina = ‘1’;
if (isset($_GET[‘pagina’])) $pagina = $_GET[‘pagina’];
- You try to read a value from the $_GET array that is not defined, so you are getting a notice-message. To resolve this, you can either test if the variable is set before reading its value: if (ISSET($_GET[‘pagina’])) $pagina = $_GET[‘pagina’]; Or you can disable NOTICE-messages with the following line at the top of your script: error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
This disables WARNINGS as well.
Source of the problem: answers.yahoo
Web site is in building
Originally posted 2013-11-09 22:46:01.