Get this from the var_dump($_FILES);

array(1) { ["gambar"]=> array(5) { ["name"]=> string(29) "Air Freshener POWER SPRAY.jpg" ["type"]=> string(11) "image/pjpeg" ["tmp_name"]=> string(23) "C:\xampp\tmp\php10C.tmp" ["error"]=> int(0) ["size"]=> int(281900) } } www.banner.comArrayINSERT INTO banner(link, gambar) VALUES('www.banner.com','Array')

I already replace $gambar with $gambar but still do not see the data inserted to database yet.

INSERT INTO banner(link, gambar) VALUES('www.banner.com','Array')

I already replace $gambar with $gambar but still do not see the data inserted to database yet.

Can you attach current file? I can still see you arer inserting an array, hence somewhere you are still using $gambar (see red colored text in quote)

the file attached.

the file attached.

Please attach sechma (SQL and connection) so that I can test full script!

I cannot attached the sql file. invalid file errors. Therefore I just copy and paste it here.

-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 16, 2011 at 10:28 AM
-- Server version: 5.5.8
-- PHP Version: 5.3.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `template`
--

-- --------------------------------------------------------

--
-- Table structure for table `banner`
--

CREATE TABLE IF NOT EXISTS `banner` (
  `id` int(3) NOT NULL AUTO_INCREMENT,
  `link` varchar(50) NOT NULL,
  `gambar` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `banner`
--

The connection to the sql file is attached. It's localhost as of now.

I have attached working file but here is your mistake, you used uploaded_file while your form says gambar. Also compare your formaer and current to see some little changes!

I have the following error for the file that gave me:

--------------
Notice: Undefined index: gambar in C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 74

Notice: Undefined index: gambar in C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 81

Notice: Undefined index: gambar in
C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 85
There was an error uploading the file, please try again!

Notice: Uninitialized string offset: 0 in C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 99

-----------

undefined index gambar (basically for the name (uploaded_file) that you replace with gambar.

it works fine with me. note that I did some little changes and I don't remember all of them. Check with your old code and see what have changed which might not be in your machine (One of the things is I commented out includes)

line 74: if(/*(!empty($_FILES)) && */(!$_FILES > 0)){

line 81: $target_path = $target_path . basename( $_FILES);

line 85: if(move_uploaded_file($_FILES, $target_path)) {

line 99: $sqlstr = "INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')";

(Notice: Uninitialized string offset: 0 in C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 99)

I checked your code, I do not know why the undefined appears after you change to . I highlighted in red the cause of the undefined. I was thinking what you did was just to be consistent with form variable name correct?

------

the codes does capture the information and put it in the database. Just there are view similar errors that I have to deal with. how to handle the undefined thing? how to define $_FILES ?

line 74: if(/*(!empty($_FILES)) && */(!$_FILES > 0)){

line 81: $target_path = $target_path . basename( $_FILES);

line 85: if(move_uploaded_file($_FILES, $target_path)) {

line 99: $sqlstr = "INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')";

(Notice: Uninitialized string offset: 0 in C:\xampp\htdocs\Masterlink\cgoods\banner_managerNEW.php on line 99)

I checked your code, I do not know why the undefined appears after you change to . I highlighted in red the cause of the undefined. I was thinking what you did was just to be consistent with form variable name correct?

------

the codes does capture the information and put it in the database. Just there are view similar errors that I have to deal with. how to handle the undefined thing? how to define $_FILES ?

did you do any change to a file or you tested the file I attached?

the codes does capture the information and put it in the database. Just there are view similar errors that I have to deal with. how to handle the undefined thing? how to define $_FILES ?

The error is explained here, here

Well, I only adjust couple things to my machine that you comment out such as the includes function("includes\koneksi") and enable the admin navigation panel. Other then that, I just tested the code that gave me.

Mmmm.. I don't quite understand the explanation so what other changes do I need to make?

Well, I only adjust couple things to my machine that you comment out such as the includes function("includes\koneksi") and enable the admin navigation panel. Other then that, I just tested the code that gave me.

Mmmm.. I don't quite understand the explanation so what other changes do I need to make?

what happens if you comment the nav pannel?

if I comment out the navigation pannel, simply the admin nav would be disappeared.

if I comment out the navigation pannel, simply the admin nav would be disappeared.

I mean does error disappear?
Let me check error level in my apache/php

finally I got it.
The problem is, when file first loaded, there is no such index as gambar in $_FILES array and hence the error. But when file is submitted then gambar is defined. So I wrapped whole gambar thing into if as attached file is. You should not get errors anymore!
BTW what is the language in comments, I was having trouble understanding some gambar et al ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.