Braveheartt Posted March 17, 2008 Share Posted March 17, 2008 Here's my code: <?php require("menu.php"); ?> <?php if(isset($_POST['submit'])) $forum_n = $_POST['name']; $bug_des = $_POST['bug_des']; $screen1 = $_POST['screen1']; $screen2 = $_POST['screen2']; $screen3 = $_POST['screen3']; $bug_type = $_POST['bug_type']; $pri_lvl = $_POST['radio']; ?> <center><font size=5 color="white"> <?php function pr(){ echo $pri_lvl; } echo "Posted by: $forum_n <br />"; echo "Description: $bug_des <br />"; echo "Screenshots: $screen1 <br />"; echo "Priority: $pri_lvl <br />"; pr(); ?></font></center> </body></html> Everything works fine, but the function pr isn't working... It won't echo $pri_lvl. Why is that? What have I done wrong ? Quote Link to comment Share on other sites More sharing options...
craygo Posted March 17, 2008 Share Posted March 17, 2008 the value is not being sent to the function try this function pr($value){ echo $value; } Now pass the value to the function pr($pri_lvl); So any value you put in the parenthesis will be echo'd out Ray Quote Link to comment Share on other sites More sharing options...
johnny44 Posted March 17, 2008 Share Posted March 17, 2008 Or if you want a function with no input, then use "global" to tell the function the value of $pri_lvl. The function doesn't know because it wasn't told. Initializing $pri_lvl earlier on in the script isn't enough. function pr(){ global $pri_lvl; echo $pri_lvl; } This will then do: pr(); "Global" picks up the value of $pri_lvl and tells the function what it is. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.