Question:
php HELP!!!: Notice: Undefined index:?
Paul Nurse
2011-07-09 15:14:06 UTC
this php code:
-----------------------------
//connect to database
include_once "../include/connect_to_mysql.php";
//then
$imgname = $_FILES["image"]["name"];
$vidname = $_FILES["video"]["name"];
$imgtempname = $_FILES["image"]["tmp_name"];
$vidtempname = $_FILES["video"]["tmp_name"];
//moves file into directory
move_uploaded_file($imgtempname , "../media/videothumbs/" . $imgname);
move_uploaded_file($vidtempname , "../media/videos/" . $vidname);
//then you have to add the names of these files and two other fileds to database
$title = $_POST['title'];
$description = $_POST['description'];
//ad all the details to database
$query = "INSERT INTO videos (title, image, description, video) VALUES ($title, $imgname, $desc, $vidname)";
$results=mysql_query($query);
?>
------------------------------
gives these error
-------------------------------
Notice: Undefined index: image in C:\xampp\htdocs\HHU\login\videoUpload.php on line 5

Notice: Undefined index: video in C:\xampp\htdocs\HHU\login\videoUpload.php on line 6

Notice: Undefined index: image in C:\xampp\htdocs\HHU\login\videoUpload.php on line 7

Notice: Undefined index: video in C:\xampp\htdocs\HHU\login\videoUpload.php on line 8

Notice: Undefined index: title in C:\xampp\htdocs\HHU\login\videoUpload.php on line 13

Notice: Undefined index: description in C:\xampp\htdocs\HHU\login\videoUpload.php on line 14

Notice: Undefined variable: desc in C:\xampp\htdocs\HHU\login\videoUpload.php on line 16
------------------------------
so here is the breakdown
----------------------------
line:
5 - imgname = $_FILES["image"]["name"];
6 - $vidname = $_FILES["video"]["name"];
7 - $imgtempname = $_FILES["image"]["tmp_name"];
8 - $vidtempname = $_FILES["video"]["tmp_name"];
13 - $title = $_POST['title'];
14 - $description = $_POST['description'];
16 - $query = "INSERT INTO videos (title, image, description, video) VALUES ($title, $imgname, $desc, $vidname)";
Four answers:
Io amo la musica!
2011-07-09 15:25:29 UTC
It seems as if there is something wrong with the previous page not sending the data/files to this page.
anonymous
2016-12-07 07:45:41 UTC
on condition that i have been coding for about 4 years now I under no circumstances inserted rapidly a superglobal variable ($_POST[], $_GET[]) rapidly right into a question. yet your important blunders is that you probably did not placed costs around the call of the variable. you probably did: $_POST[identify]; you should do: $_POST['identify']; it truly is why I also advise that you position variables to receive the post files first, then use those variables contained in the question (so that you do not bypass overboard with the costs).
Jack M
2011-07-09 15:54:47 UTC
Error #1: $description instead of $desc, you have declared the description variable as $description and when you included it in $query you typed it as $desc.



Possible errors: please check that the form syntax is similar to this:





















Be careful when you type not to have typos.
PM
2011-07-09 15:23:20 UTC
Use in the first of your PHP file .


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...