0

I would appreciate if anyone could tell me why Im getting a syntax error with this code:

if(isset($_POST['submit']))
                                    {   
$dbcon = mysqli_connect("localhost","user1","test1","tutorial");



$stored_file = $_FILES["file"]["name"];

$query="INSERT INTO store (filname, uppladdare, titel) VALUES


**Line 136->**('$_POST[**file**]$stored_file','$_POST[uppladdare]','$_POST[titel]')";
    if(!mysqli_query($dbcon ,$query));
                                        }

Notice: Undefined index: file in/Applications/XAMPP/xamppfiles/htdocs/projekt webb/laddaupp.php on line 136

The function works fine and Im storing all the data that I want. But Im still getting an error. I can always "fix" this by using reporting_error. But I prefer to learn by my mistakes.

/thanks

EDIT: The stars are not part of the coding. Just to show where the error occurs!

The final result:

$query="INSERT INTO store (filname, uppladdare, titel) VALUES ('$stored_file','$_POST[uppladdare]','$_POST[titel]')";

Thanks for the answers pals!:)

Winterwind
  • 117
  • 9

1 Answers1

0

I think you can use variable$stored_file Where you just stored your filename

$query="INSERT INTO store (filname, uppladdare, titel) 
VALUES ('$stored_file','$_POST[uppladdare]','$_POST[titel]')";

There is no $_POST['file']$stored_file in your $_POST As the error says there is no index for $_POST['file']

Fabio
  • 23,183
  • 12
  • 55
  • 64