Ok, let me clarify things a little bit for you. First, the $project is not the file name, nor is it the issue. It is not the variable. It is the relationship of what the uploaded file is associated with. Secondly, the $project comes form a session variable because it is kept alive across different pages, and is what the user is dealing with at any given time, in this part of the website. And where do you see that it is coming from a passed URL variable? The object I am dealing with is passed thru a $_POST variable from a form. It is a file name, not the $project name.
As for why I want to print the MySql error, it is both for troubleshooting purposes and to let the user know there was an error on the upload. However, mostly for troubleshooting on the MySql error, as, this is a developing script still, and I want to know what issues I am running into. On the other hand, if there is an error, I need to let the user know that there was an error and tell them why. I see your point about the relation of the mysql and upload errors, but I still need my own indications of errors. And yes, I also have a clause in there to indicate an upload error. Your message of
if(empty($_SESSION["project"]))
{
die("Project is empty!");
}
has nothing to do with any problem, as $project is not even in the picture, it is something else entirely and it has no issues.
As for
if you store the file names in a database, it time to change this technique to rename the uploaded files to the created mysql row's primary number to protect special characters, such as white space in your date!, and other special characters such as ":" ???
, the filename is the basename of the uploaded file with the project name appended to the front of it with an underscore in between. This is how the file is actually stored in the file system, and how the files are seperated from each other. There could be fifteen files called 'bass.mp3', but only one will be associated with the project, thusly, the file would be called 'myproject_bass.mp3', no matter what the file name that they upload.
So, I can see your possible confusion as to what is needed here, as you were addressing the issue of the $project being what is needing to be addressed. However, this is not the case. To sum up, as I said, the script works fine, the file is uploaded and renamed and saved into the directory, however, I still have not received any valid help on how I can retrieve the base filename into a variable to store into the database. The $project is NOT the filename, and it is NOT the issue. And the check for a duplicate occurs on the uploaded file, to see if one with that name already exists, and once again, is completely different from $project. $project can have multiple files associated with it.
Ice