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
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.
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.