jmahdi Posted May 30, 2011 Share Posted May 30, 2011 Hi there I'm trying to insert audi files' records into mysql database this is how the records insertion looks like: $fileName = $_FILES['uploaded']['name'];//name $tmpName = $_FILES['uploaded']['tmp_name'];//temp location $fileSize = $_FILES['uploaded']['size'];//size of the file $fileType = $_FILES['uploaded']['type'];//type of file $error = $_FILES['uploaded']['error'];//verifys errprs $ext = substr($fileName, strrpos($fileName, '.') +1); //this will get the extention out of the file name e.g. .mp3 //check that a file is passed by and no errors if(isset($fileName) && $error == 0 && $fileSize != 0){ //condition to accept only certain file types/extentions if($ext == "mp3" || $ext == "wma" || $ext == "wav"){ //get file content $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } //query to retrieve user's id $userid = mysql_query("select userID from user where username = '$username'"); //to get id by username $row = mysql_fetch_assoc($userid); $userid = $row['userID']; $query = "INSERT INTO tracks (trackName, userID, tag, price, file, fileName, fileSize, fileType) VALUES ('$tname','$userid','$tag','$price','$content','$fileName','$fileSize' , '$fileType)"; mysql_query($query) or die (mysql_error()); when i send it i get this error: Unknown column 'application' in 'field list' i did set data type for the fileType field to varchar. when i remove the fileType all together the record is inserted successfully into database though. ?!! can anyone help please Quote Link to comment https://forums.phpfreaks.com/topic/237818-unknown-column-in-field-list-error-is-a-headache/ Share on other sites More sharing options...
Pikachu2000 Posted May 30, 2011 Share Posted May 30, 2011 Add the missing single quote after '$fileType and see if that takes care of the problem. It's also a good idea to echo the query string along with the error while you're developing. Quote Link to comment https://forums.phpfreaks.com/topic/237818-unknown-column-in-field-list-error-is-a-headache/#findComment-1222108 Share on other sites More sharing options...
QuickOldCar Posted May 30, 2011 Share Posted May 30, 2011 I believe you are missing a quote change this $query = "INSERT INTO tracks (trackName, userID, tag, price, file, fileName, fileSize, fileType) VALUES ('$tname','$userid','$tag','$price','$content','$fileName','$fileSize' , '$fileType)"; to this $query = "INSERT INTO tracks (trackName, userID, tag, price, file, fileName, fileSize, fileType) VALUES ('$tname','$userid','$tag','$price','$content','$fileName','$fileSize','$fileType')"; Pikachu2000 is too fast Quote Link to comment https://forums.phpfreaks.com/topic/237818-unknown-column-in-field-list-error-is-a-headache/#findComment-1222109 Share on other sites More sharing options...
jmahdi Posted May 30, 2011 Author Share Posted May 30, 2011 Add the missing single quote after '$fileType and see if that takes care of the problem. It's also a good idea to echo the query string along with the error while you're developing. Oh...silly me, i shoul've noticed anyways thanks for the quick reply....i think i need a rest Quote Link to comment https://forums.phpfreaks.com/topic/237818-unknown-column-in-field-list-error-is-a-headache/#findComment-1222111 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.