There's quite a few things wrong in your code.
This mysqli_query("INSERT INTO video ('movie') VALUE (''$name')" );
is breaking your query for three reasons.
- Wrong identifier qualifiers
- Extra quote for the VALUE
- Not executing the query
IF... that's your real code.
And no, it's not VALUE
, it's what's to the left and right of it and what you didn't do, execute the query.
Using error checking http://php.net/manual/en/mysqli.error.php on your query, would have told you about the syntax errors you made being using the identifier qualifiers for your table being regular quotes, rather than ticks or no quotes at all, and the additional quote in ''$name'
.
Consult the following on identifier qualifiers in MySQL:
You also need to assign a variable to your connection and check for errors.
$connect = mysqli_connect('localhost','root','','vuap')
or die (mysqli_error($connect));
Then add that to your query:
$result = mysqli_query($connect, "INSERT INTO video (`movie`) VALUE ('$name')" );
then
if(!$result){
echo "Error: " . mysqli_error($connect);
}
else {
echo "Success!";
}
You also don't need this, just remove it:
if(isset($_POST['submit'])){
echo "<br>".$name."has been uploaded";
};
and make sure that the folder you're wanting to upload to, has the proper permissions to write to it and that the video you're wanting to upload is within the maximum allowed size.
Consult: PHP change the maximum upload file size
Sidenote: For those who think that VALUE
isn't valid, it is in MySQL.
Consult: http://dev.mysql.com/doc/refman/5.7/en/insert.html
Example:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name,...)]
[(col_name,...)]
{VALUES | VALUE} ({expr | DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE
col_name=expr
[, col_name=expr] ... ]
Footnotes:
Your present code is open to SQL injection. Use mysqli_*
with prepared statements, or PDO with prepared statements.
Additional notes:
If you're wanting to upload the data as binary rather than a string, then you will need to use either BLOB or LONGBLOB and escape the data.
Otherwise, it will throw you an error.
I.e.:
$name = $_FILES['file']['name'];
$name = mysqli_real_escape_string($connect, $name);
Consult the manual on BLOB:
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Then the rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.