Rottingham Posted January 30, 2007 Share Posted January 30, 2007 I am having a strange problem that is driving me insane! I have a HUGE software application, and I am no DUMMY to PHP. However, I am having an issue where a function retrieves the USERID # and then passes that number to a help function. No matter what I do... that VALUE will not pass. I echo the variable I am saving it to in the original function, and it is there. I pass it to the helper function, and it is gone. I try saving it in $_GLOBAL or $_SESSION and then get it from there in the helper function, and it is gone![code]// ADD/CHANGE/REMOVE PROFILE PICTUREfunction AddPic(){ global $smarty; global $Content; $view_add = $smarty->get_template_vars("uploadimage"); // get persons ID # echo $person = $_REQUEST["id"]; // GET THE FORMS ID # PASSED // if(isset($_REQUEST["upload"])) upload_images($person); else $Content .= $view_add; show_page();}function upload_images($person_id){ global $smarty; global $Content; // Check Security Clearance if(!isset($_SESSION["User_Permissions"]["Modify"])) { $Content = message("You do not have permission to use this option.", "ERROR", MB_ERROR); return; } $img_extensions = array('jpg', 'gif', 'png', 'pdf', 'bmp'); $upload_dir = "Images/profile/pics/"; // ChurchOrg/temp $upload_file = $person_id."jpg"; // ID#.jpg $max_size = "50000"; // 5MB (1000Bytes = 1K. 1000K = 1MB. 1 MB)...[/code]The echo in AddPic spits out the ID number, but the $upload_file = $person_id.".jpg" simply produces .jpg and when I ech the $person_id it is blank! I am stumped. Again, I have tried saving that as a super global and no luck. Any suggestions?Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/ Share on other sites More sharing options...
bibby Posted January 30, 2007 Share Posted January 30, 2007 Did this happen before you started echo'ing it out?Try putting that assignment in parenths.echo ($person=$_REQUEST['blah']);This way it truly gets assigned before printing.Just a guess. Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/#findComment-172572 Share on other sites More sharing options...
akitchin Posted January 30, 2007 Share Posted January 30, 2007 are you actually running upload_photo() from within AddPic()? may sound dumb, but it's possible that upload_photo() is running from outside the function rather than inside (ie. $_REQUEST['upload'] not being set). Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/#findComment-172597 Share on other sites More sharing options...
Rottingham Posted January 30, 2007 Author Share Posted January 30, 2007 Bibby:Yes, I started echoing as a troubleshooting step to see if I was getting the right data at that stage. I will try the parentheses.Akitchin: Yes, you can see from my code example that the call to upload_images is made within the AddPic() function, and that is its only use. Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/#findComment-172859 Share on other sites More sharing options...
Rottingham Posted January 30, 2007 Author Share Posted January 30, 2007 Bump!I am 100% stumped on this...I am echoing a value, like echo ($person = $_REQUEST['id']); I then pass $person to another function like upload_($person) and in the upload_ function, the value is dead, or blank. if I pass $_GLOBAL['person_id'] = $person or $_SESSION['person_id'] = $person, it is dead in the next function call... I'm stumped.Can any one offer suggestions? I have NEVER had this happen in 2 years. I have tried rewriting the function, and same thing. I pass variables all the time and this has never happened. I have changed my PHP error/warning settings to display EVERYTHING and I get nothing.Please see my original post for actual code! Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/#findComment-173103 Share on other sites More sharing options...
akitchin Posted January 30, 2007 Share Posted January 30, 2007 this may seem silly, but if it's in the $_REQUEST superglobal to begin with, why bother even passing it? you can access it from upload_photo() directly without having to pass it through AddPic(). you could even run upload_photo($_REQUEST['id']) rather than upload_photo($person). this would tell you if it's a local var assignment issue or if it's actually passing the var that isn't working.either way, you can access $_REQUEST directly from upload_photo() instead of passing it. i would also suggest doing some verification of the content of $_REQUEST vars before using them. Quote Link to comment https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/#findComment-173217 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.