Jump to content

inserting filename to mysql


justinh

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.