PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Okay, I have an issue that's a real hair-puller so far. I've created an application that allows users to upload their images through flash into the system so that they can reuse them later or currently. That part of it works. The system also properly recognizes my INSERT query ... for the most part. The upload script is what handles the insert into the database... now for the line of code I'm having issues with:
It recognizes and handles the "$newName" insert just fine (a renamed file image that is handled by this particular file. However, for whatever reason it refuses to insert the userSes variable. I tested it by echoing it out, and $userSes reads just fine. Does session only work when the user is looking at a particular file?
1. $_SESSION holds session vars, not $_session
2. You must start the session before using session vars
3. Where did you set this session var, did you start the session there?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
session_start() is declared at the very start of the script, where it should be. The session itself isn't blank.. I tested it out in an echo and visited the page, where it showed up the way it should. The name of the file is inserted into the database, but the variable for the username is not.
This is the full script, however the only thing in it that is not working is the username session insert. The session itself is set on the main website, and this page is stored in an /inc/ folder with session_start being it's own real link.
Is it possible that the user name contains characters that may need to be escaped before putting them in the database? Perhaps you need some data validation. Just a thought. Everything else looks ok. Strip out the whitespace, etc. Are you doing all that?
The test username is simply "Teonnyn". I can load the upload.php script with nothing else running, and almost all of the information gets inserted perfectly (except for the file, with no image in the que - that just loads a seed.) It seems like upload.php, when executed by Flash, ignores the session entirely. Would it be better to use a cookie, and if so, what is the best way to do that? I did try the cookie method and that resulted in a "Cannot declare cookie because of other header" issues.
Teonnyn wrote:The test username is simply "Teonnyn". I can load the upload.php script with nothing else running, and almost all of the information gets inserted perfectly (except for the file, with no image in the que - that just loads a seed.) It seems like upload.php, when executed by Flash, ignores the session entirely. Would it be better to use a cookie, and if so, what is the best way to do that? I did try the cookie method and that resulted in a "Cannot declare cookie because of other header" issues.
I don't see how this session var would be set. Maybe your flash form is posting? If so, check the $_POST var.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I'm trying to send a variable from PHP to Flash, using Actionscript 2. I can't use LoadVars in this situation because I don't want the user to see the variable.
From a browser, this works. But if Flash calls it... '$user' is ignored entirelly. '$newName', no matter how complex it might actually be, is inserted perfectly. It seems to consistently skip over '$user' when called by another script, and a COOKIE is making no more difference - the cookie itself is set when the user logs in. Sending the username from Flash is also failing.
It does actually seem to be an ID problem. After hours of research into it, I finally came across a post where a user was complaining of the same issue, both cookies and sessions failing when an upload script from Flash called the .php server-side script. How do I set a cookie or session ID? On cookies apparently there's more too it then just declaring "setcookie".