justinh Posted December 16, 2008 Share Posted December 16, 2008 Everytime someone uploads a file, I need a record to be stored in the table tbl_files <?php session_start(); include("connect.php"); $target_path = "testing/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)){ $userid = $_SESSION['userid']; $filename = basename($_FILES['uploadedfile']['name']); $mysql_query("INSERT INTO tbl_files (id,filename,userid) VALUES('','$filename','$userid')") or die(mysql_error()); echo "The file ". basename($_FILES['uploadedfile']['name'])." has been uploaded"; echo "<meta http-equiv=\"Refresh\" content=\"2; url=index.php\">"; } else { echo "There was an error uploading the file, please try again!"; } ?> This gives me Fatal error: Function name must be a string in /homepages/29/d119570661/htdocs/wmptest.com/stbs/upload.php on line 16 I think it's talking about the $filename variable, but it echo's as a string fine. Not sure what the problem is. =/ Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/ Share on other sites More sharing options...
premiso Posted December 16, 2008 Share Posted December 16, 2008 $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); I think that should be: $target_path = $target_path . basename( $_FILES['uploadedfile']['tmp_name']); Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-716981 Share on other sites More sharing options...
justinh Posted December 16, 2008 Author Share Posted December 16, 2008 i did what you suggested, but the error still comes up Fatal error: Function name must be a string in /homepages/29/d119570661/htdocs/wmptest.com/stbs/upload.php on line 16 Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-717072 Share on other sites More sharing options...
premiso Posted December 16, 2008 Share Posted December 16, 2008 Scratch that part about the tmp_name, it should be just name. Kindly point out what you see as line 16, with how the code is pasted it is hard to tell. Thanks. Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-717077 Share on other sites More sharing options...
justinh Posted December 16, 2008 Author Share Posted December 16, 2008 $mysql_query("INSERT INTO tbl_files (id,filename,userid) VALUES('','$filename','$userid')") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-717081 Share on other sites More sharing options...
justinh Posted December 16, 2008 Author Share Posted December 16, 2008 oh duh!!! i think its the $ at the begining of mysql_query Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-717082 Share on other sites More sharing options...
DarkWater Posted December 16, 2008 Share Posted December 16, 2008 Yeah, it's the $ sign. Take that off. Link to comment https://forums.phpfreaks.com/topic/137247-inserting-filename-to-mysql/#findComment-717121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.