bruckerrlb Posted January 26, 2008 Share Posted January 26, 2008 Hello! I am trying to modify a script here, an old script, what happens is, there is a flash uploader, and this flash uploader uploads a video, when the video is complete, it runs a script. I am trying to modify this script, so that when it adds the video, it not only adds the video into the specific folder, but also adds this record in the database (to be able to call the video path back on the front end). I cannot seem to figure out what I am doing wrong though! Below is my code with comments to try and explain my theory <?php $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/UploadedFiles/"; $target_encoding = "ISO-8859-1"; echo '<pre>'; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name'])); //the below part is to test to make sure that the file is a .swf and to make sure it was uploaded if ((move_uploaded_file($arrfile['tmp_name'], $uploadfile)) && ($_FILES["file"]["type"] == "application/x-shockwave-flash")) { //get my database connection include('/../../../../includes/db_connect.php'); //insert it into the database $query = "INSERT INTO video (id, path, page) VALUES (0, '$uploadfile' , 'livevideo')"; if (@mysql_query ($query)) { print 'Successfully Added!'; } } mysql_close(); } } ?> Any help is much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/ Share on other sites More sharing options...
amites Posted January 26, 2008 Share Posted January 26, 2008 have you tried checking the individual variables to make sure they are what you think they are? Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449933 Share on other sites More sharing options...
bruckerrlb Posted January 26, 2008 Author Share Posted January 26, 2008 yep, $uploadedfile is the path to the file Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449936 Share on other sites More sharing options...
amites Posted January 26, 2008 Share Posted January 26, 2008 try it without the ID, your ID is set to auto-increment in the DB right? Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449939 Share on other sites More sharing options...
bruckerrlb Posted January 26, 2008 Author Share Posted January 26, 2008 yep, ID is my primary key, but if I take out the ID, than won't that cause problems? Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449941 Share on other sites More sharing options...
bruckerrlb Posted January 26, 2008 Author Share Posted January 26, 2008 What I mean is, if I don't add it in there, than I imagine I will just get more errors. I am kind of doing this blindly, because when I upload, the flash uploader just tells me that it's been uploaded. Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449942 Share on other sites More sharing options...
legohead6 Posted January 26, 2008 Share Posted January 26, 2008 your database connection include looks pretty dodgy, i would put one more local.. Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449952 Share on other sites More sharing options...
bruckerrlb Posted January 26, 2008 Author Share Posted January 26, 2008 I took your advice, and just decided to put the connect in the same folder, but I'm still having problems, it's still not loading in the database Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449962 Share on other sites More sharing options...
amites Posted January 26, 2008 Share Posted January 26, 2008 are you still feeding it a value for ID? if the field is set to auto-increment then there could be conflict between what your feeding it and what it thinks the value should be Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449977 Share on other sites More sharing options...
bruckerrlb Posted January 26, 2008 Author Share Posted January 26, 2008 Thanks for the advice, I tried it, but didn't get anything, not even any errors, it just never showed up in the database and the file didn't show up on the server. Now the file is not showing up at all, does anyone think it could be because of limitations in php.ini? Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-449987 Share on other sites More sharing options...
amites Posted January 26, 2008 Share Posted January 26, 2008 if the file was uploading then not likely, next thing I would try is breaking up the query a little $query = "INSERT INTO video (path, page) VALUES ('".$uploadfile."' , 'livevideo')"; \ if that doesn't work I'm not sure where to go with it without knowing more about the server and DB Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-450038 Share on other sites More sharing options...
bruckerrlb Posted January 27, 2008 Author Share Posted January 27, 2008 Hello all, thanks for your help, I think the problem was my file db_connect. I finally just decided to put the connection in the actual file without any includes. The reason for this is, it's on a backend, the uploader cannot be accessed unless the user is signed in and then they can use it. So thanks for everything! Quote Link to comment https://forums.phpfreaks.com/topic/87944-solved-upload-script/#findComment-450419 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.