473,586 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in loading a text file int mysql

3 New Member
Hello friends,
I am vaibhav
I am a new to PHP/MYSQL.I have a problem to uploading a text file into MYSQL using php, and a text file is a tabdelimited file so pleas give me solution as soon as possible .Thanks in advance.

Vaibhav
Jun 18 '07 #1
3 1970
r035198x
13,262 MVP
Hello friends,
I am vaibhav
I am a new to PHP/MYSQL.I have a problem to uploading a text file into MYSQL using php, and a text file is a tabdelimited file so pleas give me solution as soon as possible .Thanks in advance.

Vaibhav
Can you give more details? Are you using LOAD DATA LOCAL INFILE?
Jun 18 '07 #2
vaibhavkansara
3 New Member
Can you give more details? Are you using LOAD DATA LOCAL INFILE?

if($HTTP_POST_V ARS['cmdup'])
{
$user="root";
$pass="";
$dbase="attende nce";
$server="localh ost";
$conn =mysql_connect( "localhost","ro ot","") or die("Connection attempt failed - ".mysql_error() );
$db = mysql_select_db ("attendence",$ conn) or die(mysql_error ());
echo $db;
$handle = fopen ("C:\\Progra m Files\\typo3\\a ttendence\\ats. txt","r");
echo $handle."<br>\n ";
while ($data = fgetcsv($handle ,1000,"\t"))
{

$sql="insert into ats (empno,emp_name ,shift,arrvl,ou t1,in2,out2,in3 ,out3,late,earl y,wkrhr,exthr,p rs,remarks)
values('$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]')";
$result = mysql_query($sq l) or die("Invalid query: .<br>\n " .mysql_error()) ;
echo $sql;

}

in this first line it give error Resource id #4
this is the code now when i click on the upload button it insert null value into the table.so what can i do. i also used LOAD DATA INFILE but it is not working.so plz give reply immediate.

my file is like
sr_no empno empname
1 1 aaaaaa
2 2 bbbbbb
and it is a text file.
Jun 20 '07 #3
code green
1,726 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. error Resource id #4
Are you sure this is all it says?. This could be a file open error or database connection error. We have no idea because your code goes blindly ahead assuming everythig is working. Get some error trapping code in and switch on every level of error reporting.
Jun 22 '07 #4

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

Similar topics

1
11449
by: Cindy Lee | last post by:
I need to insert rows into MySql database from oracle, which I imagine is a rather common task. The path I decided to take is write a java procedure, as recommended in the manual. However, java expects a driver to connect to mysql, so I use the driver that everyone is using, mysql-connector-java-3.0.11-stable-bin.jar that can be downloaded...
0
5366
by: cmars | last post by:
Hi, I want to insert massive amounts of data in near real-time into a MySQL database. The data is in a structured binary format, and I have code that parses the data into logical data structures. Right now I can load into a MySQL database via ODBC, but I need to improve throughput. How can I bulk insert the data more efficiently? I would...
0
2306
by: Mark Fisher | last post by:
I cannot seem to store binary data as a BLOB. I used the following to create a table capable of holding a BLOB: CREATE TABLE blob_table ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, binary_stuff BLOB, PRIMARY KEY (id) );
0
2147
by: adrian GREEMAN | last post by:
When I try to import a text file with new data for an existing table I get the error "1148 - the used command is not allowed with this MySQL version." I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5. Both these GUI programmes have an "import from text file" command which I have used successfully several times to add entries to...
0
1318
by: Z. S.Ghand | last post by:
--0-1230766640-1061225344=:24593 Content-Type: text/plain; charset=us-ascii Hi All; I have written a small mysql program with c++ in linux. i compile it by g++ -L/usr/lib/mysql -I/usr/include/mysql -lsqlplus myprogram.cc it works properly. but when i want to execute it i receive this error: error while loading shared libraries:...
2
4197
by: Pindz | last post by:
Hello, I have a excel spreadsheet from which I would like to load data into a table in mysql. Can you please give me an example of the above. Thanks in advance Nagsy
4
2259
by: spwpreston | last post by:
Hello, I am new to MySQL. I am trying to load from a text file to a table, and am having problems with the fields in the text file being translated to the correct fields in the TABLE. Right now, I have a tab between each field in the text file, something like: Chicago USA 2,500,000 New York USA 5,000,000
0
2050
by: PowerLifter1450 | last post by:
Hi everyone, hoepfully someone can help me with this problem, as I am new to Linux and not so sure how to troubleshoot this problem. I installed MySQL 4.1.21 on Fedora Core two without receiving any errors, and when I do # service mysql start it starts successfully. However, when trying to get to a mysqlprompt. this happens:
8
2765
by: geert | last post by:
Hi all, I have a mac mini running maocosx 10.5 leopard I want to deploy a django project on. My backend is MySQL, and I have it running as a 64- bit app. Of course, apache2 is also running as 64-bit. MySQLdb installs with the usual warnings after applying the various patches I found here and there. These patches consist of altering...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8204
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.