I m using the following code in a PHP script I am trying to call a set of code through function calling(). When I call that function and run that script if shows me the error that the variable $querydigit is undefined.
Can any body tell me how I can call that set of code where I want it.
<?php //$querynum = $_SERVER['QUERY_STRING']; function calling() { if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==1)) {$photoname = '1'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==2)) {$photoname = '2'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==3)) {$photoname = '3'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==4)) {$photoname = '4'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==5)) {$photoname = '5'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==6)) {$photoname = '6'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==7)) {$photoname = '7'; } else if(isset($_GET[$querydigit]) && ($_GET[$querydigit]==8)) {$photoname = '8'; } } if(isset($_GET['1'])) { $querydigit = 1; $photoseries = 8; $foldername = 'founder'; calling(); } else if(isset($_GET['2'])) { $querydigit = '2'; $photoseries = 8; $foldername = 'founder'; calling; } } ?>
callingto accept an argument and pass the variable to it. Also, read about variable scope.