473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

data submit error

114 100+
Dear Friends,

I have a small problem....but hope you guys can help me out...I am unable to submit data into my database.

Here is the code......

filesubmit.htm

[HTML]<html>
<head>
<title>
My Test database file
</title>
</head>
<body>

<form method="POST" name="upload" action="dbtestfilesubmit.php">
<p>
<input type="file" name="file" size="40"></p>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>
</form>

</body>[/HTML]

dbtestfilesubmit.php

[PHP]<?php
//Connect To Database
$hostname="mysql.secureserver.net";
$username="mydb";
$password="deepak";
$dbname="mydb";
$usertable="test";
$yourfield = "file";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);

$file = $_POST['file'];
//$file = "{$_FILES['file']['name']}";

$insert_query = ("INSERT INTO $usertable VALUES ('$file')");

if(!@mysql_query ($query)) {
echo mysql_error();
}else{
echo "<br>File". $_FILES['file']['name']." uploaded<br>";

}


?> [/PHP]

Please tell me where I am doing wrong.

Thanks
Deepak
Apr 25 '07 #1
2 1313
Hi,

use enctype="multipart/form-data" in form tag for getting file .

i.e. <<form name="frmadd" action="" method="" enctype="multipart/form-data">


and also use $_FILE[file_name]name] to get file name.



And i Think we can insert only file name. not the entire data using ur code.

If you want to insert all the date so use file concepts read the data form file and store in one variable then insert into the table.
try it
Apr 26 '07 #2
deepaks85
114 100+
Thanks man...........it worked for me...........



Hi,

use enctype="multipart/form-data" in form tag for getting file .

i.e. <<form name="frmadd" action="" method="" enctype="multipart/form-data">


and also use $_FILE[file_name]name] to get file name.



And i Think we can insert only file name. not the entire data using ur code.

If you want to insert all the date so use file concepts read the data form file and store in one variable then insert into the table.
try it
Apr 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's...
2
by: Kingdom | last post by:
I have a SelectBoxes.asp page that is working with multiple selection dropdown boxes to extract data and total the selection prices. Tom & Bob were kind enough to give me a big help getting this...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a drop-down list, or input data into a text box. The user...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
3
by: nkoriginal | last post by:
Hello: I tried an script for keep my data form after reload page, but I've some errors. In this momento I runnung my own browser because we've an intranet. And for security reason, our page...
1
by: vinodkus | last post by:
HV TAKEN A DRON DOWN AND FETCH RECORD OF THREE COLUMN FROM A TABLE, AND I HAVE TAKEN A SUBMIT BUTTON.JUST I WANT TO SHOW ALL RECORD IN NEXT PAGE JUST SPLIT THEM AND STORIN IN AN ARRAY BUT IT GIVES...
4
by: ghjk | last post by:
I wan to add some data using php page to mysql db. But I got the error saying "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.