Jump to content

PHP Variable not passing Data


Rottingham

Recommended Posts

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 PICTURE
function 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!
Link to comment
https://forums.phpfreaks.com/topic/36289-php-variable-not-passing-data/
Share on other sites

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.
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!
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.